Jag undrar över hur jag skulle kunna styla till det ännu bättre, de senaste forumkommentarerna som presenteras på en extern sida. Just nu ser det ut så här: Kanske något i stil med när man skapar ett nytt inlägg att det skrivs ut '10 sekunder sedans' '5 minuter sedan' '3 dagar sedan' '1 vecka sedan' '1 månad sedan'
Eller en räknare som säger hur många som har svarat på en tråd, så som det ser ut hos http://www.sweclockers.com Se bild exempel nedan Nuvarande kod för att lägga de senaste forumkommentarerna på en extern sida:
Kod: Markera allt
<?php
// Antal Poster som ska visas från forumet
$topicnumber = 6;
// sökväg till forumet
$urlPath = "Forum";
// Database Konfiguration
include 'Forum/config.php';
$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_query("SET CHARACTER SET utf8",$link);
mysql_select_db("$dbname") or die("Could not select database");
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.forum_id != 3 AND
t.forum_id != 5 AND
t.forum_id != 7 AND
t.forum_id != 7 AND
t.forum_id != 8 AND
t.forum_id != 9 AND
t.forum_id != 11 AND
t.forum_id != 12 AND
t.forum_id != 13 AND
t.forum_id != 14 AND
t.forum_id != 16 AND
t.forum_id != 18 AND
t.forum_id != 20 AND
t.forum_id != 21 AND
t.forum_id != 22 AND
t.forum_id != 23 AND
t.forum_id != 26 AND
t.forum_id != 27 AND
t.forum_id != 28 AND
t.forum_id != 29 AND
t.forum_id != 30 AND
t.forum_id != 31 AND
t.forum_id != 34 AND
t.forum_id != 35 AND
t.forum_id != 17 AND
t.forum_id != 38 AND
t.forum_id != 40 AND
t.forum_id != 39 AND
t.forum_id != 37 AND
t.forum_id != 36 AND
t.forum_id != 41 AND
t.forum_id != 43 AND
t.forum_id != 44 AND
t.forum_id != 45 AND
t.forum_id != 46 AND
t.forum_id != 53 AND
t.forum_id != 49 AND
t.forum_id != 50 AND
t.forum_id != 51 AND
t.forum_id != 52 AND
t.forum_id != 55 AND
t.forum_id != 56 AND
t.forum_id != 57 AND
t.forum_id != 47 AND
t.forum_id != 60 AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");
print "<table style='margin:0px;' cellpadding='3' cellspacing='0' border='0' center>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr valign='middle'>
<td>
<td><img src=\"bilder\pil.png\"</td><td> <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#CCC\">
<a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\">" . $row["topic_title"] . "</a>
</td>
<td>
<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#CCC\">
<a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\">" .$row["post_text"] . "</a>
</td>
<td>
<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\"> Av: <a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\">" .$row["username"] . "</a>
</td>
<td>
<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#728FCE \">" .
date('Y-M-d H:i', $row["post_time"]) ."
</td>
</tr></font>";
}
print "</center></table>";
mysql_free_result($result);
mysql_close($link);
?>
Tack