![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 74
Rep Power: 4
![]() |
LIMIT question
have a very simple forum type page I made and since I don't know how to really use mysql well I just have all posts to a particular thread list.
I only want the top Ten to show and then at the bottom a link to next results where it will show the next ten. (organized by date; most recent) I have a topic id which each post corresponds with and a post id to identify each of the posts. Could someone help me? Maybe some suggestioins on how to... or even a short snippet I can paste in somewhere? btw, This is part of small DB project I've been trying to do so I'll probably have a couple of other questions once I get this right. Most of it's done though. Probably 80% so I'm doing decent but it's nothing real complicated either. Thanks for the help!
__________________
Lorem ipsum dolor sit amet... |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4
![]() |
Hi,
a precise shema would be great. At the moment i just can tell you a template how to do such things. Suppose a shema like this: id | name | time SELECT name FROM topics ORDER BY time LIMIT 0,10 You may have to join in additional information. So far ...
__________________
-= C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do succeed, you will blow away your whole leg. =- Bjarne Stroustrup |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2005
Posts: 74
Rep Power: 4
![]() |
Hey thanks, where you put "ORDER BY time", do I put 'time' or is there a specific function I need to use?
And how do I do a link at the bottom for next pages? I guess I could determine how many pages I want and pre-program them to display 11-20 and so on. Is there another way? Or am I better off doing it like that? I don't want pages listed for every post ever anyway just maybe 10 pages of 10 posts.
__________________
Lorem ipsum dolor sit amet... |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 74
Rep Power: 4
![]() |
Ok never mind I got it! Duh, it was so easy.
I just don't get the links to pages with the rest of the posts? Can you help me with that too? ![]()
__________________
Lorem ipsum dolor sit amet... |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4
![]() |
Hi,
again without knowing the exact shema i can't show you a specific solution. ORDER BY time just says that the entries shall be ordered by the values in the time-column. That may be the post-datetime. You can supply an additonal argument wich tells the sort-order (ASC,DESC). About the link-thing: You could put a variable into the link holding the actual limit. Suppose you are showing the pages 1 - 10 right now, the link could look sth like this. <a href="forum.php?limit=10&order=asc">Next page</a> Your script then takes limit as the startvalue for the SQL-Limit statement. $query='SELECT name FROM topics ORDER BY time LIMIT '.$_GET['limit'].',10 '; And again you would show the resultset. I hope you get the idea. Regards
__________________
-= C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do succeed, you will blow away your whole leg. =- Bjarne Stroustrup |
|
|
|
|
|
#6 | |
|
Programmer
Join Date: Jul 2005
Location: Germany
Posts: 69
Rep Power: 4
![]() |
Quote:
__________________
-= C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do succeed, you will blow away your whole leg. =- Bjarne Stroustrup |
|
|
|
|
|
|
#7 |
|
Professional Programmer
|
This might help you with pagination : http://www.phpfreaks.com/tutorials/73/0.php
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|