PHP/MYSQL if statement question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
gdrums
Forum Newbie
Posts: 7
Joined: Mon Nov 18, 2002 4:41 pm

PHP/MYSQL if statement question

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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)
Post Reply