Zikula: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  Extensions and Distributions Support ::  Modules ::  Random Image Generator...H-E-L-P!!!

Moderated by: Support Team

Bottom
Random Image Generator...H-E-L-P!!!

  • Link to this postingPosted: 18.10.2003, 03:27
    Profile Homepage
    fiahmad
    rank:
    Freshman Freshman
    registered:
     October 2003
    Status:
    offline
    last visit:
    18.10.03
    Posts:
    5
    Hey everyone,

    We have an image module on our site: http://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
  • Link to this postingPosted: 24.12.2003, 13:11
    Profile Homepage
    ah^gao
    rank:
    Freshman Freshman
    registered:
     June 2003
    Status:
    offline
    last visit:
    26.10.07
    Posts:
    27
    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/>";
  • Link to this postingPosted: 24.12.2003, 21:51
    Profile Homepage
    ctimmer
    rank:
    Helper Helper
    registered:
     February 2003
    Status:
    offline
    last visit:
    11.06.08
    Posts:
    226
    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.
  • Link to this postingPosted: 25.12.2003, 03:37
    Profile Homepage
    leason
    rank:
    Helper Helper
    registered:
     October 2003
    Status:
    offline
    last visit:
    08.11.06
    Posts:
    316
    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.
  • Link to this postingPosted: 11.02.2004, 20:44
    Profile Homepage
    filex
    rank:
    Freshman Freshman
    registered:
     February 2004
    Status:
    offline
    last visit:
    12.01.05
    Posts:
    9
    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

Start ::  Extensions and Distributions Support ::  Modules ::  Random Image Generator...H-E-L-P!!!

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to Zikula