php - Cannot get URL from Database to link -


i doing project , eternally grateful in getting url's link. have tried looking around no avail. have database (4columns). last 1 (link1) should link videos specified url.when table comes url's not clickable (is there way simplify "click me"?). here code. i've attached image of table. busting brains, thanks.

<?php     $con = mysqli_connect("localhost","feedb933_charles","pass100","feedb933_test");      // check connection     if (mysqli_connect_errno())     {         echo "failed connect mysql: " . mysqli_connect_error();     }      $sql = "select * videos";     $result = mysqli_query($con, $sql);       echo "<table>";      echo "<tr>      <th>topic1</th>      <th>subject1</th>      <th>link1</th>      </tr>";      while( $row = mysqli_fetch_array( $result)) {          $topic1 = $row["topic1"];          $subject1 = $row["subject1"];          $link1 = $row["link1"];           echo "<tr>          <td>$topic1</td>         <td>$subject1</td>         <td>$link1</td>         </tr>";     }     echo "</table>";     mysqli_close($con); ?> 

table output

try this:

<?php     $sql = "select * `videos`";     $result = mysqli_query($con, $sql); ?>  <table> <?php     while($row = mysqli_fetch_assoc( $result)) {   ?>            <tr>          <td><?php echo $row['topic1'];?></td>         <td><?php echo $row['subject1'];?></td>         <td><a href="<?php echo $row['link1']; ?>" target="_blank">click me</td>   </tr>   <?php } ?> <table> 

or can use do while loop:

    do{         echo '<tr>';          echo      '<td>'.$row['topic1'].'</td>';         echo      '<td>'.$row['subject1'].'</td>';         echo      '<td><a href="'.$row['link1'].'" target="_blank">click me</td>';         echo '</tr>';  } while($row = mysqli_fetch_assoc( $result); 

i added target attribute open link in new window.


Comments