Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
rogue3
Regular
Regular



Joined: Jul 02, 2009
Posts: 71

PostPosted: Wed Sep 15, 2010 11:49 am Reply with quote

I'm trying to create a (block? module?) that will display a random image and link from my reviews database. I will be embedding this code into my normal site html, but will be pulling all of the info from my phpnuke database. So, I just need it to pull up the image from the image field, and link to the review.

I'm not sure if I should create a block (I don't use blocks on my site) or a module or what. I use includes on my site to pull all of the 'wrapped' information around my news module, so I would just embed this php code into that.

Any ideas where to start?

_________________
PHP Nuke Version: 7.5, patched
PHP Version: 4.3.11

Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6437

PostPosted: Thu Sep 16, 2010 9:32 am Reply with quote

I did something like this for one of the sites I support using a block that picks a random image from a table that has the image as an attribute. I can probably get the code for it...

_________________
I search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
kguske







PostPosted: Thu Sep 16, 2010 11:28 am Reply with quote

Here's the code (it's old, but it works):
Code:
global $prefix, $db; 


$content='';
$numberpic = 1;
$stop = 0;
$where = "WHERE Logo not like '%DBI/Nologo.jpg%'";
$result = $db->sql_query("SELECT count(1) FROM brands $where");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
while ($stop<$numberpic) {
  srand(time()+$stop);
  $random_number = rand(0, $count-1);
  $result2 = $db->sql_fetchrow($db->sql_query("SELECT BrandID, Brand, Logo FROM brands $where LIMIT $random_number,1"));
  $bid = $result2['BrandID'];
  $brand = $result2['Brand'];
  $logo = eregi_replace(' ', '%20' , $logo); 
  $img = "<img src=\"$logo\" alt=\"$brand\"  border=\"0\">";
  $content .= "<h3>$brand</h3><br /><a href=\"modules.php?name=Brands&amp;rbop=Brand&amp;bid=$bid\">$img</a><br><br>";
/*
*/
  $stop++;
}
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©