Jump to content

mysql_num_rows of SQL query


sblake161189

Recommended Posts

Hi All,

 

I think im having one of those days when you want to rip your hair out...

 

My problem is...

 

I want to produce the total number of results in my table that match a particular query... that query in English is... calculate the total number of records where field category = C Category...

 

When im in phpMyadmin and perform a search it finds all the records that have the value of C Category in the category field. If I then choose 'show php code' i get: $sql = "SELECT * FROM `staff` WHERE `category` = \'C Category\' LIMIT 0, 30 ";

 

In my php document, i use...

 

<?php
include ('config.php');
$sql="SELECT * FROM `staff` WHERE `category` = \'C Category\' LIMIT 0, 30 ";
$result=mysql_query($sql);
$num_rows = mysql_num_rows($result);
echo $num_rows;
?>

 

But I get a blank page... what am I doing wrong?

 

Cheers

 

Link to comment
https://forums.phpfreaks.com/topic/238222-mysql_num_rows-of-sql-query/
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.