Random Pic Block
Started by BPNation, Dec 02 2005 04:51 PM
33 replies to this topic
#22
Posted 10 January 2007 - 08:09 AM
chutieu, on Jan 1 2006, 11:27 PM, said:
try this code (not mine, can't recall who the author is) . Make sure you change the bold to reflect your site
<?php
echo('<CENTER><TABLE BORDER=0><TR>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 1");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../forum/index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../forum/uploads/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
echo ('</TR><TR>');
}
echo('</TR></TABLE>');
?>
<?php
echo('<CENTER><TABLE BORDER=0><TR>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 1");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../forum/index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../forum/uploads/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
echo ('</TR><TR>');
}
echo('</TR></TABLE>');
?>
Thanks mate :-)
Gerry, on Dec 4 2006, 04:44 PM, said:
Would anyone have this for 2.2 please. This does not work.
Many thanks
Many thanks
Gerry, I have 2.2.1 and it works perfectly, check your edits. for your site, maybe permissions for folders where you store your images..
#23
Posted 15 January 2007 - 01:31 PM
Gerry, on Dec 9 2006, 03:18 PM, said:
Does not work for me, this is the error I get, anyone help please
IPB WARNING [2] mysql_fetch_array(): supplied argument is not a valid MySQL result resource (Line: 8 of /sources/action_public/uportal.php(859) : eval()'d code)
hello,
am gettting the similar error as shown above by gerry.. can anyone please help solve this.
thanks
#27
Posted 04 December 2007 - 03:00 PM
To show the pictures horizontally instead of vertically:
delete all instances of <TR> & </TR> (should be 2 each)
For Last 5 pics use idate DESC. For random pics use rand () <--These are parenthesis
* There's already a code for the randon pics I know, but that one doesn't allow you to click on the picture and it doesn't show the caption or name of the pic.
For multiple horizontal rows of images that includes Latest Pics and Random Pics:
(for example, one row of Latest 3 Images and 2nd row of Random 3 Images):
Everything in bold red below is editable
delete all instances of <TR> & </TR> (should be 2 each)
For Last 5 pics use idate DESC. For random pics use rand () <--These are parenthesis
* There's already a code for the randon pics I know, but that one doesn't allow you to click on the picture and it doesn't show the caption or name of the pic.
For multiple horizontal rows of images that includes Latest Pics and Random Pics:
(for example, one row of Latest 3 Images and 2nd row of Random 3 Images):
Everything in bold red below is editable
Quote
<?php
echo('<CENTER><TABLE BORDER=0>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY idate DESC
LIMIT 3");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../index.php?act=module&module=gallery&req=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../gallery/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>'); echo ('');
}
echo('</TABLE>');
?>
<?php
echo('<CENTER><TABLE BORDER=0>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 3");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../index.php?act=module&module=gallery&req=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../gallery/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>'); echo ('');
}
echo('</TABLE>');
?>
<a href="http://WWW.YOURFORUMWEBSITE.COM/index.php?act=module&module=gallery"><font size="2"><b>More Gallery Images Here</b></font></a>
echo('<CENTER><TABLE BORDER=0>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY idate DESC
LIMIT 3");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../index.php?act=module&module=gallery&req=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../gallery/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>'); echo ('');
}
echo('</TABLE>');
?>
<?php
echo('<CENTER><TABLE BORDER=0>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 3");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../index.php?act=module&module=gallery&req=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../gallery/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>'); echo ('');
}
echo('</TABLE>');
?>
<a href="http://WWW.YOURFORUMWEBSITE.COM/index.php?act=module&module=gallery"><font size="2"><b>More Gallery Images Here</b></font></a>
#30
Posted 16 May 2008 - 06:51 PM
I am using IPB version 2.3.5 with IPB gallery 2.2 RC3 with Unreal Portal version 2.2.3. I got the same error, but mine was caused by a connection error. To solve this, I just recoded the connection. This is my code:
You shouldn't have to change anything, but if you still have issues, let me know.
<?
echo('<CENTER><TABLE BORDER=0><TR>');
$MZresult = $this->ipsclass->DB->query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id
ORDER BY rand()
LIMIT 1");
while ( $MZrow = $this->ipsclass->DB->fetch_row($MZresult)) {
echo('<TD ALIGN=CENTER width=99%><a href="index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="uploads/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
echo ('</TR><TR>');
}
echo('</TR></TABLE>');
?>You shouldn't have to change anything, but if you still have issues, let me know.
#31
Posted 04 August 2008 - 03:32 AM
<div align="center">
<?
$imglist='';
//cartella di lettura delle immagini
$img_folder = "folder image";
mt_srand((double)microtime()*1000);
$imgs = dir($img_folder);
while ($file = $imgs->read()) {
//estensioni delle immagini
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//scelta dell'immagine iniziale (0 č casuale)
$random = mt_rand(0, $no);
$image = $imglist[$random];
echo '<a href="link to image"><img src="'.$img_folder.$image.'" width="148" border=0></a>';
?>
</div>without ipgallery
just replace your image folder path
#32
Posted 03 October 2008 - 10:04 PM
I have found a fault in the overall function of this code. It will display images from a private gallery as well. Any way to fox this?
<?php
echo('<CENTER><TABLE BORDER=0><TR>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 1");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../ipb/index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../ipb/uploads/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
echo ('</TR><TR>');
}
echo('</TR></TABLE>');
?>
#33
Posted 30 January 2009 - 11:56 AM
eyepuppy, on May 16 2008, 08:51 PM, said:
I am using IPB version 2.3.5 with IPB gallery 2.2 RC3 with Unreal Portal version 2.2.3. I got the same error, but mine was caused by a connection error. To solve this, I just recoded the connection. This is my code:
You shouldn't have to change anything, but if you still have issues, let me know.
<?
echo('<CENTER><TABLE BORDER=0><TR>');
$MZresult = $this->ipsclass->DB->query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id
ORDER BY rand()
LIMIT 1");
while ( $MZrow = $this->ipsclass->DB->fetch_row($MZresult)) {
echo('<TD ALIGN=CENTER width=99%><a href="index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="uploads/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
echo ('</TR><TR>');
}
echo('</TR></TABLE>');
?>You shouldn't have to change anything, but if you still have issues, let me know.
Works like a charm. works on 2.3.6 and gallery 2.2.4
and change the LIMIT 1 To 5 or more like you wish
Tank you.
#34
Posted 02 June 2010 - 11:33 AM
Gerry, on 09 December 2006 - 08:18 AM, said:
Does not work for me, this is the error I get, anyone help please
IPB WARNING [2] mysql_fetch_array(): supplied argument is not a valid MySQL result resource (Line: 8 of /sources/action_public/uportal.php(859) : eval()'d code)
I get this same error. . .
anyone know how to fix this?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












