I have the following code that generates a list of links pulled from a database :
<?php
if ($myrow = mysql_fetch_array($result)) {
do {
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!";
}
?>
This works well if all the entries in the database have map information associated with the (Longitude and Latitude), but that's not always the case. Thus, as I execute this code, I'd like the printf function to change depending on the existance of map data. If there is map data (i.e. $Longitude has a value), then I want this printf:
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"]);
otherwise, use this printf:
printf("<LI><A HREF=\" %s \">%s</A> - \"%s\"\n", $myrow["ID"], $myrow["URL"], $myrow["SiteName"], $myrow["Description"]);
Given that I order these by SiteName, there will be some with, and some without map values.
So, how can I best accomplish this. I know with If..Then you can use :
If ($Longitude == <value>)
{ Then Statment }
Else
{Else Statement};
But, how can I make it test for $Longitude having any value at all?
Does this make sense? Is it better to use the While statement?
Thanks!
Mark