Page 1 of 1

PHP/MYSQL if statement question

Posted: Mon Nov 18, 2002 4:41 pm
by gdrums
Sorry all, this is a trully newbie question I'm sure, but I'm making the transition from ColdFusion dev to PHP, and I'm having a problem with getting the equiv of a recordcount function in ASP or CF.

Here is the code:

<?php
$Result = mysql_query("SELECT * FROM EMPLOYMENT WHERE CATAGORY='Executive' order by catagory");
if (count($Result) > 0) echo "<h2>Executive</h2>";
while ($Row = mysql_fetch_row($Result))
{
echo"
<p><font class=p><a href=index.php?fuseaction=company.jobdesc&employ_id=$Row[0]>$Row[8]</a></font></p>";
}
?>

Any ideas? Line 3 seems to be the problem, it still displays even though the query is not returning any results.

Thanks

Greg

Posted: Tue Nov 19, 2002 2:42 am
by volka
mysql_query returns a ressource identifer not the results themselft.
int mysql_num_rows ( resource result) returns the amount of recordsset you can get e.g. with array mysql_fetch_row ( resource result)