ash_dev15 ash_dev15 - 1 year ago 57
SQL Question

Link is redirecting in local host instead of actual website

I have a table with different column. on of them is website, which should redirect me to a website when clicked upon. however it is looking the website up in my local host.

it should be

here is the code for the table:


include ('db_connect.php');

$sql="select * from institution";

$result= mysqli_query($conn, $sql);

while ($row = mysqli_fetch_array($result)){

echo "<tr>";
echo "<td>" . $row['ins_id'] . "</td>";
echo "<td>" . $row['ins_name'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row['contact'] . "</td>";
echo "<td><a href=" . $row['website'] . ">" . $row['website'] . "</a></td>";
echo "<td>" . $row['email'] . "</td>";

echo "</tr>";
echo "</table>"

What should i do to make it go to the website?
Thank you in advance.

Answer Source

You need to prepend your URL with http:// or https://

echo "<td><a href='http://" . $row['website'] . "'>" . $row['website'] . "</a></td>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download