timgolding
11-13-2007, 10:48 AM
Hi I have a MySQL database and a script that get data from a table
<?PHP
$query = sprintf("SELECT * FROM courses",
mysql_real_escape_string($code));
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$index=$row['code'];
$stack[$index]['title']=$row['title'];
$stack[$index]['description']=$row['description'];
$stack[$index]['level']=$row['level'];
$stack[$index]['code']=$row['code'];
$stack[$index]['active']=$row['active'];
}
?>
This works fine. What I need to be able to do is have the script tell me if the table was empty so I don't attempt to render an empty html representation. Is this possible without the aid of an additional query?
<?PHP
$query = sprintf("SELECT * FROM courses",
mysql_real_escape_string($code));
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$index=$row['code'];
$stack[$index]['title']=$row['title'];
$stack[$index]['description']=$row['description'];
$stack[$index]['level']=$row['level'];
$stack[$index]['code']=$row['code'];
$stack[$index]['active']=$row['active'];
}
?>
This works fine. What I need to be able to do is have the script tell me if the table was empty so I don't attempt to render an empty html representation. Is this possible without the aid of an additional query?