Here's some code I'm trying to get working :
$db = mysql_connect("xxx", "xxx", "xxx");
mysql_select_db("xxx",$db);
if ($Location) {
$result = mysql_query("SELECT ID, Longitude, URL, SiteName, Description FROM rv WHERE SubCategory = '$SubCat' AND Location = '$Location' AND Status <> 'HIDDEN' ORDER BY SiteName",$db);
} else {
$result = mysql_query("SELECT ID, Longitude, URL, SiteName, Description FROM rv WHERE SubCategory = '$SubCat' AND Status <> 'HIDDEN' ORDER BY SiteName",$db);
}
.
.
.
<?php
if ($myrow = mysql_fetch_array($result)) {
do {
if ($myrow["Longitude"] == "") {
printf("<LI><A HREF=\" %s \">%s</A> - \"%s\"\n", $myrow["URL"], $myrow["SiteName"], $myrow["Description"]);
} else {
printf("<LI><A HREF=\"../map_test.php?ID=%s&Cat=rv\">[Map]</A> <A HREF=\" %s \">%s</A> - \"%s\"\n", $myrow["ID"], $myrow["URL"], $myrow["SiteName"], $myrow["Description"]);
}
} while ($myrow = mysql_fetch_array($result));
} else {
echo "Sorry, no records were found!";
}
?>
Basically, when info gets pulled from the database, if there is no value for $Longitude, then the first printf gets executed, otherwise the second one does. I cannot get this to work with an if..then statement, and a while statement doesn't seem appropriate.
That leaves the foreach() statement. I'm not sure how to implement that given my code above. Can anybody provide some assistance?
Thanks!
Mark