Thread: Last forum post
View Single Post
  #1  
Old 25th August 2010, 10:56
Edgein's Avatar
Edgein Edgein is offline
Senior Member
 
Join Date: Sep 2008
Netherlands
Posts: 154
Default
Add in index where you want

PHP Code:
///////////////////////////////////////////////// LAST X FORUM POSTS

    
print("<table id=torrenttable border=1 cellspacing=0 cellpadding=5><tr>".
  
"<td class=tabletitle align=left>Topic Title</td>".
  
"<td class=tabletitle align=left>Posts</td>".
  
"<td class=tabletitle align=left>Views</td>".
  
"<td class=tabletitle align=left>Author</td>".
  
"<td class=tabletitle align=left>Last Post</td>".
  
"</tr>");

  
$res mysql_query("SELECT posts.id AS pid, posts.topicid, posts.userid AS userpost, posts.added, topics.id AS tid, topics.userid AS usertopic, topics.subject, topics.forumid, topics.lastpost, topics.views, forums.name, forums.minclassread, forums.postcount, users.username, topicposter.username AS tusername
  FROM posts, topics, forums, users, users AS topicposter
  WHERE posts.topicid = topics.id AND topics.forumid = forums.id AND posts.userid = users.id AND topics.userid = topicposter.id AND minclassread <=" 
$CURUSER["class"] . "
  ORDER  BY posts.added DESC 
  LIMIT 5"
);

  while (
$postsx mysql_fetch_assoc($res))
  {
  
  print(
"<tr><td><a href=\"forums.php?action=viewtopic&topicid={$postsx["tid"]}&page=p{$postsx["pid"]}#{$postsx["pid"]}\"><b>{$postsx["subject"]}</b></a><br />in <a href=\"forums.php?action=viewforum&forumid={$postsx["forumid"]}\">{$postsx["name"]}</a></td>".
  
"<td align='right'>{$postsx["postcount"]}</td>".
  
"<td align='right'>{$postsx["views"]}</td>".
  
"<td><a href=userdetails.php?id={$postsx["usertopic"]}><b>{$postsx["tusername"]}</b></a></td>".
  
"<td>{$postsx["added"]}<br />by <a href=userdetails.php?id={$postsx["userpost"]}><b>{$postsx["username"]}</b></a></td></tr>");
  
  }
print(
"</table>");
///////////////////////////////////////////////// END LAST X FORUM POSTS 
Reply With Quote
The Following 5 Users Say Thank You to Edgein For This Useful Post:
Fynnon (27th September 2010), MRxp (24th May 2013), nicukent (6th November 2011), Security (25th August 2011), Tibys08 (29th May 2011)