homepage Welcome to WebmasterWorld Guest from 54.211.219.68
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Query database to output rows 11-20, not 1-10
Beyond Order By
itledi

5+ Year Member



 
Msg#: 3587162 posted 3:37 pm on Feb 28, 2008 (gmt 0)

I'm using PHP to access a MySQL table containing multiple articles with different published dates.

I would like to query this database for output, and have the most recent article on top.

mysql_query("SELECT * FROM articles ORDER BY published DESC LIMIT 10");

Works great.

However, on a second page, I would like to list articles 11-20 instead of 1-10. How can I do this?

 

wheelie34

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3587162 posted 7:23 pm on Feb 28, 2008 (gmt 0)

try 11, 10 in place of the 10 it will grab result 11 and the next 10 results

mysql_query("SELECT * FROM articles ORDER BY published DESC LIMIT 11, 10");

It would be better to do some proper pagination that extra pages are created on the fly, thats if you result set is going to keep growing. Saves headaches later

itledi

5+ Year Member



 
Msg#: 3587162 posted 2:29 am on Mar 2, 2008 (gmt 0)

Thank you very much, it works great!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved