runnerjp Posted October 15, 2008 Share Posted October 15, 2008 currently my script is set up to get new posts <?php session_start(); require_once '../settings.php'; $sql = "Select * from forumtutorial_posts WHERE lastrepliedto != 0 ORDER BY lastrepliedto DESC LIMIT 10"; $result = mysql_query($sql) or die("Could not get threads"); echo '<table width="100% border="0" > <td bgcolor="#ffffff"> <center> <b>New Posts</b> </center></td>'; $i = 0; while($row = mysql_fetch_assoc($result)) { $color = (($i%2 == 0) ? '#C7D6D6' : '#99b3b4'); echo "\n".' <tr bgcolor="'. $color .'"> <td> <center><a id="posts" href="http://www.runningprofiles.com/members/index.php?page=message&forum='.$row['forum'].'&id='.$row['postid'].'">'.$row['title'].'</a></center></td> </tr>'; $i++; } echo ' </table>'; ?> the line of code in specific is $sql = "Select * from forumtutorial_posts WHERE lastrepliedto != 0 ORDER BY lastrepliedto DESC LIMIT 10";... now how wrong could i have been to do this lol.. what i should be doing is ordering it by last 10 replies via time.,, now i store time via showtime so how would i get the last 10 posts via time :S $sql = "Select * from forumtutorial_posts ORDER BY showtime DESC LIMIT 10"; Link to comment https://forums.phpfreaks.com/topic/128605-solved-getting-new-posts-from-forum/ Share on other sites More sharing options...
runnerjp Posted October 16, 2008 Author Share Posted October 16, 2008 ok i now have my script set so it gets the time of the last post $sql = "Select * FROM forumtutorial_posts ORDER BY UNIX_TIMESTAMP(`lastrepliedto`) DESC LIMIT 0, 10"; but how do i make it so it sets it does not get the values set as 0 ( if i dont have a last replied to then it sets itself as 0 so i dont want this to show) Link to comment https://forums.phpfreaks.com/topic/128605-solved-getting-new-posts-from-forum/#findComment-666916 Share on other sites More sharing options...
Andy17 Posted October 16, 2008 Share Posted October 16, 2008 Never actually done this before but I think you can insert the following in your query: WHERE lastrepliedto > 0 Assuming that you don't store negative numbers. Link to comment https://forums.phpfreaks.com/topic/128605-solved-getting-new-posts-from-forum/#findComment-666924 Share on other sites More sharing options...
runnerjp Posted October 16, 2008 Author Share Posted October 16, 2008 THANKS... that worked but im trying to get them to go down in descending order so newest posts are 1st and only displays top 10 results... this should be simple i have the code as <?PHP $sql = "Select * FROM forumtutorial_posts WHERE lastrepliedto > 0 ORDER BY UNIX_TIMESTAMP(`lastrepliedto`) DESC LIMIT 0, 10";?> Yet it still displays the newest post 1st?[/code] Link to comment https://forums.phpfreaks.com/topic/128605-solved-getting-new-posts-from-forum/#findComment-666932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.