Hallo!! thank you all who have been contributing to help me developing my site. I have a problem with my forum. I want it to display only top 20 latest posts, currently what it does, it puts the latest post at the bottom,can anyone out there help me <?php include "include/constants.php"; //mysql db connection here echo "<link rel='stylesheet' href='style.css' type='text/css'>"; echo "<a href='post.php?user=$session->userid' > <div class='newTopic'>New Topic?,Click here</a></div>"; echo "<table class='maintable' cellspacing=0 >"; echo "<tr class='headline'> <td width=40%>Topic</td> <td width=20%>Topic Starter</td><td>Replies</td><td>Last replied time</td></tr>"; $getthreads="SELECT * from forum where parentid='0' order by lastrepliedto DESC"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); echo "<tr class='mainrow'> <td><A href='message.php?id=$getthreads3[postid]'>$getthreads3[title]</a></td> <td>$getthreads3[author]</td> <td>$getthreads3[numreplies]</td> <td>$getthreads3[showtime]<br>Last post by <b>$getthreads3[lastposter]</b></td> </tr>"; } echo "</table>"; ?> many thanks tldmic
You should display it using query and limit option use query like this select * from table limit 0,20 that will fetch only 20 records
Which CMS are you using for the forum? Almost all of them like vBulletin, IPB, MyBB, SMF has mods which will display the latest posts.
you can put it in mysql_query mysql_query("select * from table limit 0,20 that will fetch only 20 records"); Code (markup):
thank you i was able to figure that one out ..... limit 0,20"; thanks but what about the posting of the new post to be at the top, how do I go about changing that ? I want to display the latest post at the top, can you please advice on that ?