Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-15-2002, 01:04 AM   PM User | #1
wap3
Regular Coder

 
Join Date: Aug 2002
Location: UK
Posts: 324
Thanks: 0
Thanked 0 Times in 0 Posts
wap3 is an unknown quantity at this point
Php querying mysql !!

Hey everyone

If I have a simple query such as

select name from tableone where name = whatever

How can I add on a count to the end of it. In other word have something that counts the reords returned and puts that value into a variable, e.g $counttotal

Any help appreaciated ??

wap3 is offline   Reply With Quote
Old 11-15-2002, 11:23 AM   PM User | #2
bcarl314
Mega-ultimate member


 
Join Date: Jun 2002
Location: Winona, MN - The land of 10,000 lakes
Posts: 1,855
Thanks: 1
Thanked 45 Times in 42 Posts
bcarl314 will become famous soon enough
Here's one way.
Code:
$result=mysql_query("SELECT count(name) FROM tableone WHERE name=whatever",$linID);
$tot=mysql_fetch_association($result);
I believe there's also a mysql_num_rows which gives you the total rows returned from a result set.
bcarl314 is offline   Reply With Quote
Old 11-15-2002, 02:09 PM   PM User | #3
wap3
Regular Coder

 
Join Date: Aug 2002
Location: UK
Posts: 324
Thanks: 0
Thanked 0 Times in 0 Posts
wap3 is an unknown quantity at this point
Thanks bcarl

Just what I was after !!

wap3 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:58 AM.


Advertisement
Log in to turn off these ads.