开发者

CodeIgniter - retrieving all posts except the last from table

My scenario:

  • I want to post all threads from a table in my DB, except for the very last one. I've tried to use select_max, but it doesn't work. I can't seem to figure out what to put in my query string.
开发者_StackOverflow中文版

I just want to retrieve all posts and offset it by 1.


Something like this might work:

SELECT * FROM table ORDER BY id DESC LIMIT 100,1 (limit 100, offset by 1)

or you get all the posts and in when looping through them in codeigniter you could do something like this:

$i = 1;
foreach($posts as $p):
    if($i != 1):
        //show posts
    endif;
$i++;
endforeach;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜