I am getting values from a mysql database and displaying them in a 1 column table. I am wanting to display these values as links to their appropriate URL which is the value from the database + .html appended to the end. Here is the code I am using to do this. And it is not working.
<html>
<body>
<?php
/* Connecting, selecting database */
$link = mysql_connect("localhost", "user", "password")
or die("Could not connect");
print "Connected successfully";
mysql_select_db("Anykey") or die("Could not select database");
/* Performing SQL query */
$query = "SELECT * FROM GlobalPref_Table";
$result = mysql_query($query) or die("Query failed");
/* Printing results in HTML */
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
$link = $col_value . ".html";
print "<td><a href=$link>$col_value</a></td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($link);
?>
</body>
</html>
What is happening, it the first value gets the .html appended to it, but the remaining values do not. I don't know what I am doing wrong. I have only been using PHP for 2 days. Any help would be appreciated.
Thanks
Gregg