Jump to content

[SOLVED] Problem Counting


Canman2005

Recommended Posts

Hi all

 

I have the following query

 

SELECT COUNT(*) as Num FROM files GROUP BY categoryid

 

The problem is that if I run this query in phpmyadmin, I get a total of 4, which is right. But if I run this query within a php page, I only get 2 as a result.

 

Can anyone tell me why I get a different result?

 

Any advice would be great

 

Thanks

 

Ed

Link to comment
https://forums.phpfreaks.com/topic/48044-solved-problem-counting/
Share on other sites

Yep, 100%, the whole query code is

 

	$total = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM files GROUP BY categoryid"),0);
print $total;

 

and my database looks like

 

id 	categoryid
223 	9
224 	9 
225 	10
226 	10
227 	10
228 	11
229 	11
230 	11
231 	12

 

Can anyone see anything that is wrong?

 

Thanks

 

Ed

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.