Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] Php ordering, help.

Started by gamerking Nov 18, 2008 at 7:35 PM 2 replies 1.4k views
Original Post
gamerking
gamerking
Hey I have a question which I couldn't think up an answer for myself; and am coming to see if I can grab a tip or two. Here my problem: I have a food etc. comments list which people need to fill out, the catergory with the newest review raises to the top of the page, and here in lies my problem. I don't know how to get that simple ordering process going. SELECT * FROM items WHERE type='c' ORDER BY datelisted. This returns all comments. But I can't figure out how to orginize it. You see I need it to go type->preview of results (shows 4 latest comments). Start again until it hits the page limit. my problem is how do I know which item is at the start I have type set as either c or i which is item or comment so how do I get it to grab the item then grab the two newest comments while keeping it all from newest to oldest? Thanks for the help, please feel free to ask if you need anymore information. So lets say: Apple gets 8 new comments in the last minute (last 2mins ago) bannana gets 1 in the last 5(last 4mins ago) and orange gets 4 in the last 15 (last 8minutes ago) How can I get it to go: apple Comment newest Second newest banna comment newest Second newest orange comment newest second newest.
Matt : mattb0001@hotmail.comClick me please
gamerking
gamerking
Thanks but don't worry rather than looking for some mythical command I 'll just add a last post field into the database.

Thanks anyway :)
Matt : mattb0001@hotmail.comClick me please
NBlaine
NBlaine
You might try something like:

SELECT *
FROM Items
ORDER BY item_type, datelisted DESC

This would get you your result set, then just print the item name and other information as you normally would.
Mr Purple
Mr Purple
Something like this:

SELECT * FROM items WHERE type='c' GROUP BY datelisted

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.