[SOLVED] Determining whether an array contains any values
Posted: Wed Oct 20, 2004 10:43 am
I have a mysql table that I want to list its contents. However, if there is nothing in the table I want to print a message instead.
Currently I'm using this code:
This will list the contents of the table. However, if the table is empty because it contains no data, I want to print a message instead. I've tried various if else statements but have had no success because I'm not sure how to evaluate the array.
Thanks for your help.
Currently I'm using this code:
Code: Select all
$crs_array = @mysql_query("SELECT * FROM schedchgs ORDER BY ADDDEL");
if (!$crs_array) {
die('<h2>Error retrieving schedule changes from database!</h2><br>' .
'Error: ' . mysql_error());
}
echo ('<table border="0" align="center">');
while ($crs_row = mysql_fetch_array($crs_array)){
echo ('<tr><td width="60%">'.$crs_row[INFO].'</td><td>'.$crs_row[ADDDEL].'</td></tr>');
}Thanks for your help.