Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/87158-a-more-complex-pagination/
Share on other sites

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?

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?

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.

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?

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?

Well, it's not hard. :D

 

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.