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
https://forums.phpfreaks.com/topic/199982-find-last-post-number-from-limit-2/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.