Page 1 of 1

php blog - mysql select problem

Posted: Sat May 03, 2008 6:23 am
by kozmk
hey guys,

I'm trying to script my own blog, but I have a problem.
On the homepage I got the script to show the last 5 post that have been made, but now I want to show "older" post so it I need a page that skips the first 5 post and shows the next 5 post. How can I get this info out of mysql ?


thanks

Re: php blog - mysql select problem

Posted: Sat May 03, 2008 7:04 am
by matthewl
at the moment i assume that you are using LIMIT 5 at the end of your sql query.

LIMIT can also take the offset so LIMIT 5,5 will give you records 6-10

Re: php blog - mysql select problem

Posted: Sat May 03, 2008 7:16 am
by kozmk
ah no , I was using another system, gone try that out :) thanks alot m8

Re: php blog - mysql select problem

Posted: Sat May 03, 2008 7:21 am
by matthewl
When your dealing with mysql, you will find that a lot of things mysql is quicker at doing than php, so its always worth checking to see if mysql can do something before you do it in php. Sorting, limiting, joining tables will always be quicker in mysql.