Helpful Information
 
 
Category: vBulletin.org Forum
Last 10 threads error !

Please help.
Could you go to www.visordown.com/forums and click on office pal at the top.

Apparantly it does not owrk which is really annoying.

anyway here is the code


<HTML>
<HEAD>
<TITLE></TITLE>
<STYLE type=text/css>



A:active {COLOR: #000000 ;}
A:visited {COLOR: #333333 ; text-decoration: none ;}
A:hover {COLOR: #666666; text-decoration: underline ;}
A:link {COLOR: #000000; text-decoration: none ;}

</STYLE>
</HEAD>
<body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0 bgColor="#FFFFFF">
<br>
<center><font face="verdana" size="2"><a href="javascript:window.location.reload()">Click here to refresh</a>&nbsp;&nbsp;&nbsp;<a href="javascript:window.close();">Click here to close window</a></center>

<!-- ## START THREAD TABLE ## -->

<br>
<?php

require("http://www.visordown.com/forums/global.php");

$db_link = @mysql_pconnect("$dbservername", "$dbusername", "$dbpassword");
mysql_select_db("$dbname");

?>

<table cellpadding="4" cellspacing="1" width="100%">
<tr bgcolor="#DDDDDD">
<td><font color="#000000" face="verdana" size="2"><small><strong>Show the last 10 threads</strong></small></td>
<td align="center"><font color="#000000" face="verdana" size="2"><small><strong>REPLIES</strong></small></td>
<td align="center"><font color="#000000" face="verdana" size="2"><small><strong>VIEWS</strong></small></td>
</tr>
<?php
$lastten = lastten();
while( $row = mysql_fetch_row($lastten) )
{
print('<tr bgcolor="#F2F0F0">');
print('<td>');
print('<font size="2" face="verdana"><a href="http://www.visordown.com/forums/showthread.php?s=&threadid=');
print($row[0]);
print('" target="_blank">');
print($row[1]);
print('</a></td>');
print('<td align="center">');
print($row[2]);
print('</td>');
print('<td align="center">');
print($row[3]);
print('</td>');
print('</tr>');
}
mysql_free_result ($lastten);
?>
</table>

<?php

function lastten()
{
$query = 'SELECT threadid, title, replycount, views ' .
'FROM thread ' .
'WHERE (' . $cur_time . '-lastpost) < 604800 ' .
'ORDER BY threadid DESC LIMIT 10';
$result = mysql_query($query)
or die('most_viewed query failed');
return($result);
}

?>


</BODY>
</HTML>


(I have snipped out the top3 posters as i dont want that)


Could you help me make it work, and ideally I woudl like to show the last 10 posts not threads.

I know its a long shot, but I hope it can be done.

cheers,

~veedee

Did you even bother to read global.php before you included it? Or noticed that it included db_mysql.php? Or noticed that you are already connected to the database and provided with a group of functions to interact with the MySQL db already?

I don't think so. I wish people would bother to do a little more research on their own.

Originally posted by leadZERO
Did you even bother to read global.php before you included it? Or noticed that it included db_mysql.php? Or noticed that you are already connected to the database and provided with a group of functions to interact with the MySQL db already?

I don't think so. I wish people would bother to do a little more research on their own.

Sorry mate didnt realise this was the bad reactions party.

I know squat about PHP so when something goes wrong, people help and i *gradually* pick things up.

I have search for it, had a look at hot scripts for tutorials, tried on my own, but still nothing. I have asked 3 people on icq, no solutions there.

Were you born with PHP installed in your brain or did someone stop off along the way to share their *precious* time to help you then, so that now you can shred me in your replies as you know it all.

Community spirit, conceptualised in your reply I would say.

sorry to waste your time reading and replying to a thread, i should have thought about you when i posted it.
:(

Not everyone is PHP expert as you leadZERO. Someone knows that and someone knows this. We share our knowledge to learn something new and that's why we post posts like this one - to help someone else and show him/her a way to do it correctly and the most efficiently.
I don't think you your self would be pleased by response like this.

Please, consider your words before you click on submit.

Try this :)

lastten.php<?php

$templatesused = "lastten,lasttenbit";
require ("./global.php");

$threads = $DB_site->query("
SELECT thread.*, forum.*,
thread.title AS threadtitle,
forum.title AS forumtitle
FROM thread
LEFT JOIN post ON (post.threadid = thread.threadid)
LEFT JOIN forum ON (forum.forumid = thread.forumid)
GROUP BY thread.threadid
ORDER BY thread.lastpost DESC LIMIT 0,10");

while ($thread = $DB_site->fetch_array($threads)) {
if (($counter++ % 2) == 0)
$backcolor = "{ secondaltcolor }";
else
$backcolor = "{ firstaltcolor }";
$lastpost = vbdate("$timeformat $dateformat", $thread[lastpost]);
eval("\$lasttenbits .= \"".gettemplate('lasttenbit')."\";");
}

eval("dooutput(\"".gettemplate('lastten')."\");");

?>template - lastten{ htmldoctype }
<HTML>
<HEAD><TITLE>$pagetitle</title>
$headinclude
</head>
<body>
$header

<!-- border colour table -->
<table cellpadding=0 cellspacing=0 border=0
bgcolor="{ tablebordercolor }" width="{ tablewidth }" align="center">
<tr><td>

<table cellpadding=4 cellspacing=1 border=0 width=100%>
<tr bgcolor="{ tableheadbgcolor }">
<td colspan=5><normalfont color="{ tableheadtextcolor }"><b>Last ten modified threads</b></normalfont></td>
</tr>
<tr bgcolor="{ firstaltcolor }">
<td><smallfont>Thread</smallfont></td>
<td><smallfont>Forum</smallfont></td>
<td><smallfont>Replies</smallfont></td>
<td><smallfont>Views</smallfont></td>
<td><smallfont>Last Post</smallfont></td>
</tr>
$lasttenbits
</table>

</tr></td>
</table>
<!-- /border colour table -->

$footer

</body>
</html>
template - lasttenbit<tr bgcolor="$backcolor">
<td><normalfont><a href="showthread.php?s=$session[sessionhash]&threadid=$thread[threadid]">$thread[threadtitle]</a></normalfont></td>
<td><normalfont><a href="forumdisplay.php?s=$session[sessionhash]&forumid=$thread[forumid]">$thread[forumtitle]</a></normalfont></td>
<td><normalfont>$thread[replycount]</normalfont></td>
<td><normalfont>$thread[views]</normalfont></td>
<td><normalfont>$lastpost</normalfont></td>
</tr>
You will need to remove the spaces from all the {xxx} replacement variables.

I think that was what you were asking for? :)

Big thanks to PeF, SgtSling, and Kier for helping me on this, both over ICQ and here.

I have to say sorry for basically asking for people to hold my hand through the whole process, but I did get completely stuck.

No worries as I am happy again :)


STOP !!!











CARRY ON !!

~veedee










privacy (GDPR)