Jump to content

mysql_num_rows help


Go to solution Solved by trq,

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
Share on other sites

  • Solution

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.