Jump to content

Find last post number from limit 2


runnerjp

Recommended Posts

If i use a query to limit results to 2

 

$small=mysql_query("select * from {$prefix}comments where msg_id_fk='130' order by com_id limit $second_count,2 ");
while($rowsmall=mysql_fetch_array($small))
{ 

 

how could i find the com_id number of the lastone so if i run a query again i can carryon from that number so something like

 

$com=mysql_query("select * from comments where msg_id_fk='130' and com_id > '$thenumber' order by com_id");?>

 

 

E.G - limit two would be

 

3

4

 

 

then if i ran

$com=mysql_query("select * from comments where msg_id_fk='130' and com_id > '4' order by com_id");?>

 

i would get the remainder

 

5

6

7

8

9

Link to comment
Share on other sites

Just use LIMIT starting at $second_count+2 with an arbitrary large number for the second parameter.

 

$com=mysql_query("select * from comments where msg_id_fk='130' and com_id > '4' order by com_id limit $second_count+2, 999999");

 

EDIT: I *think* you can add values in a limit clause. If not you will just need to do the addition before you create the query.

Link to comment
Share on other sites

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.