Puntocom
Well-known member
I have written this code, I post here hoping it to be useful for you:
PHP:
<?php
$hostname = "localhost";
$db_username = "USERNAME";
$db_password = "PASSWORD";
$link = mysql_connect($hostname, $db_username, $db_password) or die("Cannot connect to the database");
mysql_select_db("DATABASE") or die("Cannot select the database");
$q = "SELECT thread_id,title,username,first_post_id FROM xf_thread WHERE first_post_id > 0 ORDER BY thread_id DESC LIMIT 0,10";
$r = mysql_query($q);
echo "<ul>";
while ($row = mysql_fetch_array($r)) {
$title = utf8_encode($row["title"]);
$first_post_id = $row["first_post_id"];
$limit = 26;
if (strlen($title) > $limit)
$title = substr($title, 0, strrpos(substr($title, 0, $limit), ' ')) . '...';
$tid = $row["tid"];
echo "<li><a target=\"blank\" href=\"http://www.YOURDOMAIN/posts/$first_post_id\">$title</a></li>";
}
echo "</ul>";
?>