Hi,
I have the following piece of PHP code (sorry for its layout). It gets results from a query and displays them in a two column wide table. Is there a way I can print a message and not display an empty table if there are no query results?
<?
$query = \"AN SELECT STATEMENT\";
// run the query on the database
$result = mysql_db_query($db,$query ,$connection);
// display the result
echo \"<table align=center width=450 border=1 cellspacing=0
cellpadding=0>\";
echo \"<tr><td width=100 align=left><h3>BUS</h3></td><td width=100 align=left><h3>TIME</h3></td></tr>\";
// with a while loop
// this loop will iterate as many times as there are records
while($myrow = mysql_fetch_array($result))
{
$start = $myrow[\"ROUTE_ID\"];
$destination = $myrow[\"ARRIVE_TIME\"];
echo \"<tr><td width=150 align=left>$start</td>
<td width=100 align=left>$destination</td></tr>\";
}
// free up used memory
mysql_free_result($result);
?>
</table>
Many Thanks!
I have the following piece of PHP code (sorry for its layout). It gets results from a query and displays them in a two column wide table. Is there a way I can print a message and not display an empty table if there are no query results?
<?
$query = \"AN SELECT STATEMENT\";
// run the query on the database
$result = mysql_db_query($db,$query ,$connection);
// display the result
echo \"<table align=center width=450 border=1 cellspacing=0
cellpadding=0>\";
echo \"<tr><td width=100 align=left><h3>BUS</h3></td><td width=100 align=left><h3>TIME</h3></td></tr>\";
// with a while loop
// this loop will iterate as many times as there are records
while($myrow = mysql_fetch_array($result))
{
$start = $myrow[\"ROUTE_ID\"];
$destination = $myrow[\"ARRIVE_TIME\"];
echo \"<tr><td width=150 align=left>$start</td>
<td width=100 align=left>$destination</td></tr>\";
}
// free up used memory
mysql_free_result($result);
?>
</table>
Many Thanks!