SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Location
    Internet
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I have problems with my random images

    I have problems with my random images, not show me an "imagen",

    Here is the code
    PHP Code:
    <?  
    function random_images($path) {  
    $F 0;  
    $dir opendir($path);  
    while (
    $file readdir($dir)) { if (($file != ".") || ($file != "..")) { $archivos[$F] = $file$F++; } }  
    $muestra rand(1,$F);  
    return 
    "<img src=/$path/$archivos[$muestra]>";  
    }  
    ?> 
    <?  
    echo random_images("file_images/myimages");  
    ?>
    Here is the example with the grafics of my Random Images

    Thank you
    Last edited by jaesflo; Jun 13, 2007 at 17:08.

  2. #2
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your randomly-generate index is going from 1 to $F; your array indexes are instead going from 0 to $F-1.
    PHP Code:
    $muestra rand(1,$F)-1
    If this isn't your problem could you please restate it more clearly?
    PHP questions? RTFM
    MySQL questions? RTFM

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ( $muestra 10 )
      
    $muestra $muestra
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


Bookmarks

Posting Permissions

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