Results 1 to 2 of 2

Thread: Multiply randon images

  1. #1
    Join Date
    Jul 2010
    Posts
    2

    Multiply randon images

    Hi,

    I'm developing an internet forumand part of it will be a 'featured van' section. At the moment we only have 8 (I think) featured vans. This will increase and I cant fit them all across the screen.

    I've used PHP load a randon image from a list on each page load and something similar to this would work but for multiple images.

    I would need it to select 8 randon pix from a list or directory and display them in a horizontal strip, and a pix is selected it will not try and select it again until the page is relaoded - I wouldn't want 2 pics of the same van in 1 strip.

    I can't find any 'of the shelf' goodies to help me do this.

    Does anyone have any ideas?

    The forum is http://thelatebay.com, and the current banner is quite obvious.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2010
    Location
    England
    Posts
    1,144
    As you already have a database for your forum ( im assuming so anyway ), then just make another table and put them into that.

    Then you can just do a select statement like this:
    PHP Code:
    $r mysql_query"SELECT * FROM van_images ORDER BY RAND() LIMIT 8" );
    while( 
    $rw mysql_fetch_assoc$r ) ){
        echo 
    "<img src=\"" $rw['image_source'] . "\" />";

    Considering you have a database already, and you say new images might be added, thats probably the way i would do it
    ---

    Otherwise you could put each image into an array: eg,
    PHP Code:
    $vans = array ( 'van.jpg''van2.jpg''van3.jpg' );

    $vans shuffle$vans );

    for( 
    $i 0$i 9$i++ ){
         echo 
    "<img src=\"" $vans[$i] . "\" />";


Similar Threads

  1. e-mailings with absolute links to images
    By Cervantek in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 30 May 2009, 10:49 AM
  2. Replies: 1
    Last Post: 16 Jul 2007, 02:46 PM
  3. Concept Feedback: Digg.com but for images
    By angmi90 in forum General Questions
    Replies: 1
    Last Post: 02 Aug 2006, 07:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •