I managed to get the paging to work, almost. I want to show the user the total number of records found and the currently displayed records. Example:
4000 found, displaying 0-100.
I am testing this with nr 2 (because I don't have entries like 20). Therefore, I use LIMIT $start, $nr_results;
Do I have to make two queries to display the results the way I want, one query that retrieves all the records, and then do mysql_num_rows to get all the records, and then using LIMIT?
I have it:
mysql_num_rows($qry_result); $total_pages = ceil($num_total / $res_per_page); //$res_per_page==2 and $num_total = 2 if ($p - 10 < 1) { $pagemin=1; }
else {$ pagemin = $ p - 10; } if ($ p + 10> $ total_pages) {$ pagemax = $ total_pages; } else {$ pagemax = $ p + 10; }
Here is the request:
SELECT mt.*, fordon.*, boende.*, elektronik.*, business.*, hem_inredning.*, hobby.* FROM classified mt LEFT JOIN fordon ON fordon.classified_id = mt.classified_id LEFT JOIN boende ON boende.classified_id = mt.classified_id LEFT JOIN elektronik ON elektronik.classified_id = mt.classified_id LEFT JOIN business ON business.classified_id = mt.classified_id LEFT JOIN hem_inredning ON hem_inredning.classified_id = mt.classified_id LEFT JOIN hobby ON hobby.classified_id = mt.classified_id ORDER BY modify_date DESC LIMIT 0, 2
Thanks, if you need more input let me know.
Basically, Q is, do I need to make two queries?
user188962
source share