umraz Posted March 1, 2011 Share Posted March 1, 2011 Hi I needed pagination for this please help <?php $id = $_GET['id']; $queryitem = "SELECT * FROM item WHERE idsub = '$id' ORDER BY name"; $resultitem = mysql_query($queryitem); while($dataitem = mysql_fetch_assoc($resultitem)){ ?> Data < <?php } ?> Link to comment https://forums.phpfreaks.com/topic/229246-pagination-needed/ Share on other sites More sharing options...
litebearer Posted March 1, 2011 Share Posted March 1, 2011 Extremely easy to implement class - http://phpsense.com/php/php-pagination-script.html example usage - http://www.nstoia.com/sat/disp_pag/ Link to comment https://forums.phpfreaks.com/topic/229246-pagination-needed/#findComment-1181226 Share on other sites More sharing options...
monkeytooth Posted March 1, 2011 Share Posted March 1, 2011 Pagination occurs based on the amount of rows pulled out from the DB. First you must get that count, then you must run math based on that count for how many results you want per page. So if your query there pulls 20 records and you only want 5 per page, then your static max per page would be 5.. So then you want to count the total rows pulled by your query. So you can do that math. 5 / 20 = 4 so that means you should have 4 pages Pagination isn't a quick one liner or even a few liner.. As such, your current query doesnt support the concept. As you need to limit your results you need to select where to get your results from (starting at which row, in accordance with that limit). You need to also compensate for what if you get 21 records, and only need to pull one record for that 6th page. On another note, its better to come here and ask for help on what your stuck with. Not with what you want us to do for you instead. You will get more answers here if you simply give an actual problem rather than say I need this, please help.. something like that makes most of us think you dont want help achieving the desired goal, you just want one person to come along, do it.. and you just copy and paste it, then away you go Not tryin to be mean, just informative.. Link to comment https://forums.phpfreaks.com/topic/229246-pagination-needed/#findComment-1181232 Share on other sites More sharing options...
umraz Posted March 1, 2011 Author Share Posted March 1, 2011 Em noob in php please help please make the code and post it here Link to comment https://forums.phpfreaks.com/topic/229246-pagination-needed/#findComment-1181239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.