Page 1 of 1
new pages....
Posted: Sun May 04, 2003 2:42 pm
by AndrewBacca
im designing this site for a friend of mine who sells motorbike gear and he wants to display all his products that he sells on the site, but ive noticed that he has alot of stuff.
What i thought about doing was have about 25 iteams per page, so it loads 25 iteams and continues on another page "page1, page2, page3..." type thing.
I have all the data stored in a MYSQL database, any ideas on how i can do this.
if you need more info, just ask
cheers
Andrew
Posted: Sun May 04, 2003 5:20 pm
by delorian
The simplest solution is to count all the products. Divide the returned number by 25 to know how many page links you'll have to create. Then the links could look something like this:
Code: Select all
list.php?start=0&stop=25 // for page1
list.php?start=26&stop=50 // for page2
// etc.
Then you must show the products from start number to stop number only. I think that will work.
Another thing to do is to put that start-stop numbers in database query. You must have the id column so you can use this to get the right records. But if you remove one of the product, then the id will also be removed so on one page you could see 24 not 25 products.

Posted: Sun May 04, 2003 6:56 pm
by patrikG
use the mysql
LIMIT
which provides that you have some index-column, e.g. "id"
SELECT * FROM articles ORDER BY ID ASC LIMIT 0,24
which pulls the first 25 records from your DB-table. To pull the next 25 you would simply change LIMIT 25,49 and so on.
The actual numbers in your index-column "id" don't matter, they are only there to provide an index-framework.
Posted: Mon May 05, 2003 1:58 am
by []InTeR[]
patrikG wrote:which pulls the first 25 records from your DB-table. To pull the next 25 you would simply change LIMIT 25,49 and so on.
Nope, LIMIT 25,49 will give you 49 records starting with the 25th.
To pull the next 25 records out of your database use LIMIT 25,25.
Off corse you can use a varable for the starting record.
Posted: Mon May 05, 2003 5:16 am
by patrikG
^
|
|
right
<--- wrong