limited number of postings on a webpage/number of postings

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bxm_3
Forum Newbie
Posts: 13
Joined: Sun Nov 20, 2005 6:23 pm

limited number of postings on a webpage/number of postings

Post by bxm_3 »

I wish to have the first 100 postings on a forum on the first webpage, the second 100(101-200) on the 2ndpage, the next 100 postings on the 3rd page(301-400).

I know the sql code for the 1st page - select * from table order by ID limit 100, but for the 2nd page I do not know the code, I do not know how many postings or do I do a calculation.

If I have a posting which can be identified in 3 ways the posting relative to the total number of postings, the current topic(question) number and the postings within the topic(question).

If I wish to post all posting in a topic(question) would I have a querystring link in the hyperlink for each posting.
This could be applied to the total number of topics(questions).

If I wish to organise the postings in terms of topic and postings within the topic would the sql code be

select * from table order by topic asc and topicpost asc/select * from table order by topic asc and time asc /
select * from table order by topic and topicpost asc/select * from table order by topic and time asc
where time is the time of posting.

The trouble this with the sql statement is that is that the 1st posting in each topic can be posted then the 2nd posting in each topic instead of all postings in each topic.

to keep the number of posting in each topic to for example 100 would you the sql code look like

select * from table order by topic asc and topicpost asc limit 100/select * from table order by topic asc and time asc limit 100/
select * from table order by topic and topicpost asc limit 100/select * from table order by topic and time asc limit 100

However, this would only work for the first 100 postings(see top of the page).

where time is the time of posting.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

SELECT * FROM table_name LIMIT 100, 200

Code: Select all

SELECT * FROM table_name LIMIT 200, 300
etc
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

I got bored after reading the first bit.

Sounds like you need to search for pagination, this forum has some nice snippets in the Code Snippets section, check it out.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

the keyword for a search that will return many good threads is: pagination.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Something tells me you might be looking for pagination, not sure though, maybe 3 or 4 more replies telling you to search for pagination will confirm that you need to search for pagination.

/bored.
Post Reply