gardan06 Posted January 22, 2008 Share Posted January 22, 2008 First, let me start by saying that i know how to do basic paginations using the limit function in mySQL. Anyway, here's my query: $query1 = mysql_query("select sku from replenish_detail"); while ($row = mysql_fetch_array($query1)) { $query2 = mysql_query("select * from sku_location where sku='".$row['sku']."'"); $row2 = mysql_fetch_array($query2); if ($row2['qty'] > 0) { /* do <tr><td></td></tr> stuff here that doesnt really need further explanation */ } } My question is, how am i going to be able to use pagination on this when my page couldnt depend on the limit(x,y) command in mySQL. Your help is greatly appreciated. Thank you. Jay Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/ Share on other sites More sharing options...
teng84 Posted January 22, 2008 Share Posted January 22, 2008 thats weird? but you can you use loop eg.. $ctr =0; $limit = 5;//records while($row =mysql_fetch_array($query)){ $ctr++; if($ctr < $number){ //do something here if(++$x > $limit){ break; } else{//do something here } }else{ continue; } } is that what you mean? Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-445780 Share on other sites More sharing options...
gardan06 Posted January 22, 2008 Author Share Posted January 22, 2008 My question is, how am i going to be able to use pagination on this when my page couldnt depend on the limit(x,y) command in mySQL. I'm figuring this one would be a lot tougher because you have to probably include a counter within the if ($row2...) statement. That's not a problem on the first page because you will start on the first row, but when you try to get the 2nd page onwards, it will be hard because you'll start maybe from row#5 or 10 or whatever. Jay p.s. how come i couldnt edit my first post? thats weird? but you can you use loop eg.. $ctr =0; $limit = 5;//records while($row =mysql_fetch_array($query)){ $ctr++; if($ctr < $number){ //do something here if(++$x > $limit){ }else{ continue; } } i was thinking that, but how can i continue that on the 2nd page onwards? do i have to repeat the query all over again from the first row, but only show the row that is needed on the page? Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-445782 Share on other sites More sharing options...
teng84 Posted January 22, 2008 Share Posted January 22, 2008 yes that how i understand the question.. are you sure you know paging? Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-445787 Share on other sites More sharing options...
gardan06 Posted January 22, 2008 Author Share Posted January 22, 2008 yes that how i understand the question.. are you sure you know paging? of course man, its simply obtained by the using "select * from table limit(x,y) where x is the starting row and y is the number of rows shown. in my script, does it mean that for every page, i still have to find out what the very first row is? i guess it will be if there is no other way, but that's why i'm here, to find out if there IS another way. Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-445796 Share on other sites More sharing options...
teng84 Posted January 22, 2008 Share Posted January 22, 2008 in my script, does it mean that for every page, i still have to find out what the very first row is? i guess it will be if there is no other way, but that's why i'm here, to find out if there IS another way. sorry i still dont get it.. i wonder if it was my bad english that makes me hard to understand you? Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-445812 Share on other sites More sharing options...
gardan06 Posted January 22, 2008 Author Share Posted January 22, 2008 in my script, does it mean that for every page, i still have to find out what the very first row is? i guess it will be if there is no other way, but that's why i'm here, to find out if there IS another way. sorry i still dont get it.. i wonder if it was my bad english that makes me hard to understand you? well, fortunately, im also filipino. maybe we can talk through private messaging using tagalog instead? Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-445820 Share on other sites More sharing options...
gardan06 Posted January 22, 2008 Author Share Posted January 22, 2008 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-445915 Share on other sites More sharing options...
gardan06 Posted January 23, 2008 Author Share Posted January 23, 2008 i still have this problem so if anyone can give me a hand on this, i'd really appreciate it. sorry for the bump. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-446526 Share on other sites More sharing options...
teng84 Posted January 23, 2008 Share Posted January 23, 2008 Oh man.. PM and ill try to solve this.. your explanation really makes no sense to me;) Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-446569 Share on other sites More sharing options...
Ken2k7 Posted January 23, 2008 Share Posted January 23, 2008 Well, it's not hard. For the page links, instead of saying something like: blah.php?page=2, you would put blah.php?page=50 (or wherever your results stopped.) So then you can just get that number and loop from there, right? Of course, I have NO idea why you would choose this kind of pagination. Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-446593 Share on other sites More sharing options...
cooldude832 Posted January 23, 2008 Share Posted January 23, 2008 the whole point of the mysql LIMIT function is to reduce the info that has to be collected on a query saving time. I don't see what you are trying to do with a x,y limit are you saying you have a limiter on 2 independent variables/table, if this is the case you should be running the two in separate queries. Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-446606 Share on other sites More sharing options...
sasa Posted January 23, 2008 Share Posted January 23, 2008 use just one query to pull data something like this SELECT shu_location.* FROM replenish_detail LEFT JOIN sku_location ON sku_location.sku=replenish_detail.sku AND sku_location.qty>0 LIMIT... Quote Link to comment https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/#findComment-446627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.