Hello everyone, I am having trouble implementing COUNT in a query and would like some advice
Given a query like
SELECT * FROM #__sometable ORDER by value DESC LIMIT 0, 20
I already get the records but how can I get those 20 records plus the total amount of records in that table, what I am trying to do is provide a table which displays the records, 20 at a time and provide a list of numbers say 1, 2, 3, 4 where 1 represents records 0-20, 2 represents 21-40 and so on but want to create those numbers dynamically, so if the table contains only 20 records I want to be able no to print those numbers but if the table contains 60 records then I want to place the numbers 1, 2, 3 with a link to make the query to the respective results, in that case if I click on 3 I will dynamically create a query like
SELECT * FROM #__somtable ORDER by value DESC LIMIT 41, 20
I know I can use COUNT but don't know how to implement it in the same query so I don't have to query the database twice
you don't need COUNT
look up the FOUND_ROWS function in da manual
Thank you for the quick answer, I read it and that does get the number of rows however I do still have to run another query right?
no, just your SELECT (using the SQL_CALC_FOUND_ROWS option), then retrieve the value of FOUND_ROWS
Okay, I will try it, thank you for your help!
This topic is now archived. It is frozen and cannot be changed in any way.