Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Help

Status
Not open for further replies.

perlone

Programmer
May 20, 2001
438
US
Hello,

I'm making a message board and what I want to do is make all posts with a new reply to the top of the board, just like tek-tips.com. For the mysql part, here's what I have:

$sql = <<EOF;
select * from boards where bid = '$f'

order by pid desc
EOF

pid is the post id. If I put something like 'order by replies desc', the new posts with 0 replies will go down instead of going to the top.

I was wondering if anyone have any suggestions on how to do this. Thanks again and let me know if you need more info. There is no Knowledge that is not power.
Age: 16
E-mail: projectnet01@yahoo.com
School: Coral Springs High (Company:(not done yet) :)
Status: Currently working with C++ for game developing. And making a musical band.
-Aaron
 
What i did in this situation is to have 2 tables
Table 1. Title
(ID, Title, Last Replied Time, etc..)
Table 2, Message
(ID, etc. etc.)

Then all you do is just order by Last Replied Time and it put the newest post on top. However, doing it this way require you to update 2 tables when you insert a new post.

If you only want to use 1 table then you can use something like (ID, title, message, time, etc.) and then when you write something like Select * FROM tbl_name GROUP BY Title ORDER BY time.

Hung-Hsun Su
 
Thank you so much! There is no Knowledge that is not power.
Age: 16
E-mail: projectnet01@yahoo.com
School: Coral Springs High (Company:(not done yet) :)
Status: Currently working with C++ for game developing. And making a musical band.
-Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top