...

View Full Version : how do I make a query span several pages



sean paul
08-30-2002, 10:25 AM
Instaed of presenting the query results all at once I would like the query to span at least ten pages.

How do I do this using PHP and mySQl.

thanks:o

freakysid
08-31-2002, 04:09 PM
You do this by using a LIMIT clause at the end of your query:

eg:

SELECT * tableName
WHERE foo='foo'
ORDER BY foo
LIMIT 0,10

That will give you the first ten results (sorted by column foo by alphabetical order)

SELECT * tableName
WHERE foo='foo'
ORDER BY foo
LIMIT 10, 10

That will give you the next ten results - starting at an offset of 10 (ie, starting at the 11th record).

SELECT * tableName
WHERE foo='foo'
ORDER BY foo
LIMIT 20, 10

The next ten records (21-30)

etc. So you can hold the offset and number values in a variable in your php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum