Jump to content

mysql_num_rows help


Recommended Posts

Everything works great, except the part where I am trying to get the mysql_num_rows for each category - $jobsc_row['job_category']
 

<?php
$jobsc_query = "SELECT j.id, j.jobc_name, c.job_category FROM site_jobscats AS j LEFT JOIN site_jobs AS c ON j.id=c.job_category WHERE jobc_active='1'";
$jobsc_result = mysql_query($jobsc_query) or die("There was a problem with the SQL query: " . mysql_error());
while ($jobsc_row = mysql_fetch_array($jobsc_result)) {
   $jobcatid = $jobsc_row['id'];
   $jobcatname = $jobsc_row['jobc_name'];
   $jobcatcount = mysql_num_rows($jobsc_row['job_category']);
   echo "<li><a href=\"jobs.php?cat=$jobcatid\">$jobcatname [$jobcatcount]</a></li>";
}
?>
Link to comment
https://forums.phpfreaks.com/topic/277480-mysql_num_rows-help/
Share on other sites

No kidding. mysql_num_rows returns the number of rows contained within a result resource and expects to be passed a result resource. Your result resource is in $jobsc_result but that won't help you.

 

What your trying to do is find the size of a simple array. Replace mysql_num_rows() with count().

 

And please, turn error reporting on when writing code!!!

Link to comment
https://forums.phpfreaks.com/topic/277480-mysql_num_rows-help/#findComment-1427437
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.