Hi everyone, I've been a reader for a long time, now I've joined up, as I'm fairly stumped on this one!!
I'm currently teaching myself mysql and php at work, and have a problem. I am using php to produce a listing of restaurants on a page, and I would like to do the following at the end of each line:
1) If the website field is not blank, display the url (or even just "Website")
2) Make the URL Clickable, and open in a new window.
I've managed to produce the list, however my code has gone south somewhere as the "website" field is displaying even when there is no entry in the database. Also when the link is present it's clickable, but opening in the same window. Can someone help me and tell me where I've gone wrong?
<?php
mysql_connect(HOST,USER,PASS);
@mysql_select_db("db303278079") or die( "Unable to select database");
$query="
SELECT * FROM restaurants";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$rest_name=mysql_result($result,$i,"rest_name");
$address=mysql_result($result,$i,"address");
$telephone=mysql_result($result,$i,"telephone");
$website=mysql_result($result,$i,"website");
$cuisine_type=mysql_result($result,$i,"cuisine_type");
$area=mysql_result($result,$i,"area");
echo "<strong>$rest_name</strong>, $address, $telephone, ($cuisine_type), $area, <A HREF=$website>'Website'</a><br >";
$i++;
}
?>
Thanks in advance for your help :)