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!
I am writing a script that needs to pull all users from a relational table. I would like to return the total number of users affiliated but I would also like to limit the array fetched to a suitable number to be displayed on the screen (say.. 6)..
$total_num = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
//this will get data for every user... i don't want to do that.
$data[] = $row;
}
Whats the best way to control the amount of the total actually fetched? I would try and use LIMIT {$users_displayed} in my query but that trumps the total users affiliated question....
Suggestions?
Your description sounds contradictory. Either you want to return all the rows or you don't. If you need two sets, it would take two queries. Perhaps you want to return all the rows but only display some? You would do that by using a for loop (or a while loop) as you echo the data to be displayed. What is it that you are trying to do??
Thanks for the reply.. sorry if I wasn't clear... but maybe your right...
I want to:
1. get a total number of users affiliated (e.g. you have 22 users affiliated)
2. only output a certain lower number. (e.g. user1 - user2 - user3- user4 etc...)