Jump to content

Counting Records very confused...


monkeytooth

Recommended Posts

I've tried this multiple times, it used to work like a charm too, lately though not so much. I have tried to count them 2 ways..

 

One:

$totalcount_query   = "SELECT COUNT(*) AS totalcount_rows FROM ".$tableName." ".$appndQ."";
$totalcount_result  = mysql_query($totalcount_query) or die('Error #SQL0003: Query Failed.');
$totalcount_row     = mysql_fetch_array($totalcount_result, MYSQL_ASSOC);
$totalcount = $totalcount_row['totalcount_rows'];

 

I run these within a function I created to make my code smaller in other areas of the site...

Now thing I should mention is that these still work I get record counts.. the issue with them is when ever I add an "AND" to my clause it fails.

 

Sometimes I require to find out if something or not already with a particular person so I want to count records like

 

WHERE user='$userID' AND itemID='$itemID'

The Above fails.. every time as far as getting a count with either mentioned at the top methods.

Now if I do the same thing minus the AND

 

WHERE user='$userID'

or

WHERE itemID='$itemID'

 

I get an actual count. Where am I getting this wrong?

 

 

Two:

$result = mysql_query("SELECT * FROM ".$tableName." ".$appndQ."");
$totalcount = mysql_num_rows($result);

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.