Brandon Jaeger Posted May 10, 2006 Share Posted May 10, 2006 I'm trying to get the last post/topic from the forum but it's not working too well. Can you tell what I did wrong just by looking at this?Thanks in advance![code] function get_last_post_by_forum($cid , $fid) { $query = "SELECT `posterid`, `timestamp` FROM `forum_posts` WHERE `forumid` = '" . $fid . "' ORDER BY `timestamp` DESC LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); $poster_id = $row["posterid"]; $stamp = $row["timestamp"]; $time = time_since2($stamp); $query = "SELECT `posterid`, `timestamp`, `forumid` FROM `forum_topics` WHERE `catid` = '" . $cid . "' ORDER BY `timestamp` DESC LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); $tpc_stamp = $row["timestamp"]; $tpc_id = $row["id"]; if($tpc_id == $fid && $tpc_stamp > $stamp) { $time = time_since2($row["timestamp"]); $poster_id = $row["posterid"]; } if($poster_id > 0) return $time . "<br \>by <b>" . name($poster_id , 1) . "</b>"; return "No posts"; }[/code] Link to comment https://forums.phpfreaks.com/topic/9458-trying-to-get-last-posttopic-from-forum/ Share on other sites More sharing options...
redarrow Posted May 10, 2006 Share Posted May 10, 2006 Somethink like that.[code] $query = "SELECT `posterid`, `timestamp`, `forumid` FROM `forum_topics` WHERE `catid` = '" . $cid . "' ORDER BY `timestamp` DESC LIMIT 1 and ORDER BY ASC"; $result = mysql_query($query) or die(mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/9458-trying-to-get-last-posttopic-from-forum/#findComment-34867 Share on other sites More sharing options...
Brandon Jaeger Posted May 10, 2006 Author Share Posted May 10, 2006 That didn't work but I figured it out!Tip: Don't code when you're tired. Especially a forum! [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] *SOLVED* Link to comment https://forums.phpfreaks.com/topic/9458-trying-to-get-last-posttopic-from-forum/#findComment-34933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.