MyBB Community Forums

Full Version: 'last 5 topics'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
doesn't work. got the error in all 4 boxes (see for yourself - I'll roll back soon)
Oohhhh...You're bringing me to the limit. Rolleyes Check your Emails.
thanks a lot,
but still 4 errors (don't know whether are different from the previous). Sad
understood, thank you. Smile
Have you tried the way of k776? I tried it and it works.

Just create 4 files for example Uscite_Recenti.php, Old_Works.php,...

Put the following code into the new files:
<?php
require("global.php");
$fid = "1"; // The id of the forum to pull posts from goes here

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads WHERE fid=$fid ORDER BY `tid` DESC LIMIT 0,5");
while ($item = $db->fetch_array($query)) {
if (strlen($item['subject']) > 24) { $subject = substr($item['subject'], 0, 20)."...."; } else { $subject = $item['subject']; }
$tid = $item['tid'];
echo "<a href=\"http://www.unprogged.com/showthread.php?tid=$tid\" target=\"_blank\">$subject</a><br>";
}
?>

In the second line you have to enter the fid of the forum. You see them in the URL.

Example: Old works -> http://www.unprogged.com/forumdisplay.php?fid=38

Upload them into the folder of your forum and put them into the iframes.
I tried to apply it to "uscite recenti" but got a fatal error (you can see it @ www.unprogged.com/portal.php). Here's what I inserted in the external php file I've created:

<?php
require("http://www.unprogged.com/global.php");
$fid = "37"; // The id of the forum to pull posts from goes here

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads WHERE fid=$fid ORDER BY `tid` DESC LIMIT 0,5");
while ($item = $db->fetch_array($query)) {
if (strlen($item['subject']) > 24) { $subject = substr($item['subject'], 0, 20)."...."; } else { $subject = $item['subject']; }
$tid = $item['tid'];
echo "<style type=\"text/css\">
<!--
.style3 {
	color: #CCCCCC;
	font-size: 9px;
	font-family: Verdana;
	font-weight: bold;
}
-->
</style>
<body STYLE=\"background-color:transparent\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td><div align=\"left\">
        <li style=\"color:#999999\" type=\"square\"><a href=\"http://www.unprogged.com/showthread.php?tid=$tid\" target=\"_parent\" class=\"style3\">$subject</a>
        </li>
      </div></td>
  </tr>
</table></body>";
}
?>

The error is the following:

Fatal error: Call to a member function on a non-object in /web/htdocs/www.unprogged.com/home/lasttopics/topics_usciterecenti.php on line 5
doh, how silly of me. Turn fid=$fid into fid='$fid' and replace http://www.unprogged.com/ with ./ in the require bit. Try that.
that works!! thank you!!

btw, the slash between the ' and the s of "Pepper's Ghost" remains...
solved on my own! however, thank you!
hi, is it possible to show the date other than the subject?

thank you very much
Other than or as well as? If you want to show both the time and subject, try this: (I'm using myBB's default time formatting so hopefully it should work and I rearanged it a bit and adding <html> and <head> tage etc so it should work better on browsers):
<?php
require("./global.php");
$fid = "37"; // The id of the forum to pull posts from goes here

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads WHERE fid='$fid' ORDER BY `tid` DESC LIMIT 0,5");
while ($item = $db->fetch_array($query)) {
if (strlen($item['subject']) > 24) { $subject = substr($item['subject'], 0, 20)."...."; } else { $subject = $item['subject']; }
$tid = $item['tid'];
$lastpostdate = mydate($settings['dateformat'], $item['dateline']);
$lastposttime = mydate($settings['timeformat'], $item['dateline']);
$time = $lastpostdate." ".$lastposttime;
?>

<html>
<head>
<title></title>
<style type="text/css">
<!--
.style3 {
color: #CCCCCC;
font-size: 9px;
font-family: Verdana;
font-weight: bold;
}
-->
</style>
</head>
<body style="background-color:transparent">
<table width="100%"  border="0" cellspacing="0" cellpadding="0"><tr>
<td><div align="left">
<li style="color:#999999" type="square"><a href="http://www.unprogged.com/showthread.php?tid=$tid" target="_parent" class="style3">$subject</a> ($time)</li>
</div></td>
</tr></table>
</body>
</html>

<?php
}
?>
Pages: 1 2 3 4 5 6