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