Hey everyone,
We have an image module on our site: www.stonybrookmsa.com
But I need one that can randlomly choose one from a specific folder...because we have several ads we want to display. Anyone know how to do this?
- Farooq
- craigh responded to »TagIt 3.0 for Zikula« 03:58 PM
- jmvaughn responded to »error when i try to upgrade to the last version of dizkus module (3.1)« 12:05 PM
- localrags responded to »Remove contents of nuke_sc_anticracker from Database« 11:30 AM
- jmvaughn responded to »Shoutit for zikula 1.3?« 09:31 AM
- mdee responded to »Different page content under one template (tpl file) based on URL« 07:17 AM
- espaan responded to »Categories disappear when editing ...« 08. Feb
- eledril responded to »How decrease zikula cpu usage« 08. Feb
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Random Image Generator...H-E-L-P!!!
-
- Rank: Registered User
- Registered: May 31, 2003
- Last visit: Oct 21, 2009
- Posts: 30
I used the core block "Core/PHP".
My photo album script from smartor.
Code
$query = "SELECT * FROM nuke_phpbb_album";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
$start = "1";
$random = mt_rand($start, $numrows);
echo "<table align=\"center\" cellspacing=\"2\" border=\"0\"/><tr/><td align=\"center\"/>";
echo "<a href=\"http://www.sgwutan.com/modules.php?op=modload&name=PNphpBB2&file=album\"/><img src=\"index.php?name=PNphpBB2&file=album_thumbnail&pic_id=$random\"/></a/>";
echo "</table/>"; -
- Rank: Softmore
- Registered: Feb 07, 2003
- Last visit: Jun 11, 2008
- Posts: 225
You might want to take a look at the MultiImage module at:
http://noc.postnuke.com/projects/multiimage/
Allows you to have a random image block. -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 292
You could streamline that code a bit as well:
Code
$query = "SELECT * FROM nuke_phpbb_album ORDER BY RAND(MD5(NOW))) LIMIT 1";
$result = mysql_query($query);
$picrow = mysql_fetch_assoc($result);
$picid = $picrow['id']; //I don't know what the column name is so you would need to insert that here instead of 'id'
echo "<table align=\"center\" cellspacing=\"2\" border=\"0\"/><tr/><td align=\"center\"/>";
echo "<a href=\"http://www.sgwutan.com/modules.php?op=modload&name=PNphpBB2&file=album\"/><img src=\"index.php?name=PNphpBB2&file=album_thumbnail&pic_id=$picid\"/></a/>";
echo "</table/>";
This allows the mysql server to do the work of finding a random row. Not sure if it is really more or less effecient, just a different way of doing it. -
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 8
Hi,
Is it possible to create a "Recent Picture" block for Smartor's album with something like what you have here for "random block"? Can anyone please post code for it here? Your help will be greatly appreciated.
TIA
- Moderated by:
- Support
