RobBroekhuis
Technical User
I'm writing a simple web forum (mysql/php), and would like to display search results 20 hits at a time. To know how many pages of hits there are, I can execute a query
select * from posts where condition=met
followed by
pages=ceil(mysql_num_rows()/20)
and to display the posts on a particular page, I can do
select * from posts where condition=met limit (page*20),20
while mysql_fetch_rows {...}
Is there a way I can get both out of one query? Would that be worth it? I'm new to mysql and don't know how it optimizes for speed, but figure that in the background, it has to do the exact same thing twice if I use two queries.
Rob
select * from posts where condition=met
followed by
pages=ceil(mysql_num_rows()/20)
and to display the posts on a particular page, I can do
select * from posts where condition=met limit (page*20),20
while mysql_fetch_rows {...}
Is there a way I can get both out of one query? Would that be worth it? I'm new to mysql and don't know how it optimizes for speed, but figure that in the background, it has to do the exact same thing twice if I use two queries.
Rob