[SOLVED] Determing Row Count

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

[SOLVED] Determing Row Count

Post by Burrito »

I need to know how many rows a query is returning...is there a built in function to do this?

I know I could do this:

Code: Select all

<?php
$count = 0;
while($row = mysql_fetch_assoc($queryname)){
$count = $count + 1;
}

?>
but that seems like a bloated way of doing things...I'm thinking there's got to be something easier that's built in....

please advise,

thx,

Burr
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]mysql_num_rows[/php_man] and [php_man]mysql_affected_rows[/php_man]
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

perfect, thank you.

Burr
Post Reply