Forum Moderators: open

Message Too Old, No Replies

Creating active URLs from mysql

how can i make my links work?

         

boinkit

11:10 pm on May 28, 2008 (gmt 0)

10+ Year Member



I am new to SQL and also PHP, but I thought I'd get stuck in and try and learn something new.
I would like to know how I can use URLs that I have stored in my database, so that they are active (clickable) on my webpage.
The very basic bit of querying that I have done, does produce what I want in an HTML page, but the URL that shows up is just dead text - and I would like it to be an active weblink.
Can anyone help?
My shoddy bit of coding to get the query results into HTML are as follows:


mysql_select_db("user_quicklinks", $con);
$result = mysql_query("SELECT * FROM quicklinks ORDER BY lastname");

echo "<table border='1'>
<tr>
<th>First Name </th>
<th>Surname </th>
<th>Username </th>
<th>Website One </th>
</tr>";
// fill box with data
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['website1'] . "</td>";
echo "</tr>";
}
echo "</table>";


mysql_close($con);
?>

LifeinAsia

11:13 pm on May 28, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I don't know PHP, but probably something like:
echo "<td><a href='" . $row['website1'] . "'>" . $row['website1'] . "</a></td>";

boinkit

11:15 pm on May 28, 2008 (gmt 0)

10+ Year Member



Spot on!
It works a treat. Thank you :-)