Ok,I've been looking around and I stumbled upon a php mysql command called mysql_num_fields. And it looks like it'll do what I want, I just want to get the total number of rows that are in a table. It looks like how this command works, it actually needs you to get all items in a table, return them and then it totals them up to see how many there are. Is there a faster way? Or is that the wrong way to go with it?
While I'm tapping into your knowledge, is there a way to have mysql just randomly grab a set number of items out of a table?
Tnaks,
Paul
How to get total of table rows?
Moderator: General Moderators
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
http://www.php.net/mysql_num_rows
As for specific number of rows I believe SELECT x WHERE z=t LIMIT n can be used (not sure its been ages since I used MySQL).
Regards
As for specific number of rows I believe SELECT x WHERE z=t LIMIT n can be used (not sure its been ages since I used MySQL).
Regards
Last edited by CoderGoblin on Tue Feb 01, 2005 9:49 am, edited 1 time in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
SELECT COUNT(*) FROM table_nameCode: Select all
SELECT * FROM table_name ORDER BY RAND() LIMIT 10Thanks for the info guys. I think I'm going to go with For grabbing a set number of items out of the DB. It worked pretty darn good and simplified what I was trying to do.
Paul
Code: Select all
SELECT * FROM table_name ORDER BY RAND() LIMIT $numberPaul