Jump to content

[SOLVED] getting new posts from forum


runnerjp

Recommended Posts

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

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)

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.