Hello Boofo,
thanks for bringing this up. I just rewrote the code and brought it down to 1 single query. :nervous:
Please implement all changes like this:
Find:
PHP Code:
// #############################################################################
// unset vB's default template vars, do this at the end so any standard error
// or redirect calls still have the vars for use in the templates.
unset($header, $footer, $navbar, $headinclude);
Above this add:
PHP Code:
// ############## PROCESS RANDOM PIC #######################################
$images = $DB_site->query("
SELECT user.userid, user.username, customprofilepic.profilepicdata, customprofilepic.comment
FROM ".TABLE_PREFIX."customprofilepic
LEFT JOIN ".TABLE_PREFIX."user USING (userid)
WHERE visible=1 and customprofilepic.profilepicdata IS NOT NULL
ORDER BY RAND()
");
$rows = $DB_site->num_rows($images);
if (!$rows)
{
//do nothing
}
else
{
$image = $DB_site->fetch_array($images);
$output_pic = "<A HREF=\"./forum/member.php?u=$image[userid]\">$image[username]<BR><BR>";
$output_pic .= "<img src=\"./forum/image.php?u=$image[userid]&type=pthumb\" border=\"0\" width=\"150\" height=\"150\"/></A>";
}
If you need comments below the pictures then...
Replace in my code above:
PHP Code:
$output_pic .= "<img src=\"./forum/image.php?u=$image[userid]&type=pthumb\" border=\"0\" width=\"150\" height=\"150\"/></A>";
With:
PHP Code:
$output_pic .= "<img src=\"./forum/image.php?u=$image[userid]&type=pthumb\" border=\"0\" width=\"150\" height=\"150\"/></A><BR>$image[comment]<BR>";
Cheers,