$num_rows not working: what have I done???
Posted: Thu May 27, 2010 5:10 am
Code: Select all
$result = mysql_query ("SELECT catid, catname FROM products WHERE pause = 'off' AND catid IS NOT NULL GROUP BY catname");
while ($row = mysql_fetch_object($result))
{
$count = mysql_query ("SELECT id, catid FROM products WHERE catid = '$row->catid");
$num_rows = mysql_num_rows($count);
mysql_free_result($count);
echo "<div class='submenu'";
if ($c != NULL && $c == $row->catid) { echo "style='background-color:#FF7200; color: #ffffff'";}
echo "><a href='index.php?page=categ&menu=sub&c=$row->catid&cname=$row->catname&head=$row->catname'>";
if ($c == $row->catid) { echo "<font color='#000000'>$row->catname <font size='1'>($num_rows)</font></a></font>";}
elseif ($c != $row->catid) { echo "$row->catname <font size='1'>($num_rows)</font></a>";}
echo "</div>";
}
mysql_free_result($result);When I run it locally I get this:
Line 13 isWarning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\phpMyAdmin\site\includes\menu\sub.inc on line 13
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\xampp\phpMyAdmin\site\includes\menu\sub.inc on line 15
Code: Select all
$num_rows = mysql_num_rows($count); I just need to have the category name, and the amount of items assigned to that category by each one.