number of records per page

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

number of records per page

Post by shiranwas »

hi,

I am having a problam with my displaying the records. i.e when i query a table it gives me all the records that matches my criterias but i want to show only 10 records in first pager and so on how to do this
please help me

shiran
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

put

Code: Select all

LIMIT 10
at the end of your query
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Actually, you will need to use this for the first page:

Code: Select all

LIMIT 0, 10
Second page:

Code: Select all

LIMIT 10, 10
Third page:

Code: Select all

LIMIT 20, 10
And so on...
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

Post by shiranwas »

hi,
yes i did that but the thing is when i go to the next page i put limit 10 offset 10, and how do i go to previous

first page

select * from tblComplaints limit 10;

second and 3 ......

select * from tblComplaints limit 10 offset 10;

but how to go back to from 2nd page to first page
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

I don't understand what you mean :?
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

Post by shiranwas »

Oren,

i am very sorry i did not see your answer before i send earlier meaasage
what you sent is correct and working as the way i want.

thank you
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Cool 8)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

If you still have problems, search the forum for 'pagination'

should be plenty of topics to help you along :)
Post Reply