SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Addict AbelaJohnB's Avatar
    Join Date
    Oct 2001
    Location
    Eureka, CA. USA
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Loading Multiple Images

    Hello.


    Ok, odd request here....

    I have a new site, and each page will have a new photograph load at the top of the page.

    However, each image is broken into three (3) cut-images.


    They are named:


    001a.jpg - 001b.jpg - 001c.jpg

    002a.jpg - 002b.jpg - 002c.jpg

    003a.jpg - 003b.jpg - 003c.jpg


    and so on.



    What I need is to random-load each FULL-IMAGE (which is broken into three images).


    Any thoughts/code on this one??



    Thanks.
    John B. Abela
    www.JohnAbela.Com

  2. #2
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where is this information stored, in the file system?
    I mean, do you have a folder somewhere with
    Code:
    001a.jpg
    001b.jpg
    001c.jpg
    002a.jpg
    002b.jpg
    002c.jpg
    003a.jpg
    003b.jpg
    003c.jpg
    004a.jpg
    004b.jpg
    004c.jpg
    files in there?

  3. #3
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    something like this..

    PHP Code:

    $img = array(1,2,3);
    shuffle ($img);

    ?>

    <img src="00<?=$img?>a.jpg" />
    <img src="00<?=$img?>b.jpg" />
    <img src="00<?=$img?>c.jpg" />

    <?

    //more php
    the neigbours (free) WIFI makes it just a little more fun

  4. #4
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    More like this:
    PHP Code:
    <?php

    $numbers 
    range (1,3);
    srand ((float)microtime()*1000000);
    shuffle ($numbers);
    $img $numbers[0];
    ?>
    <img src="00<?=$img?>a.jpg" />
    <img src="00<?=$img?>b.jpg" />
    <img src="00<?=$img?>c.jpg" />
    (from PHP manual)

  5. #5
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know I was gonna say my first suggestion was wrong and that this should be tried


    PHP Code:
    $img = rand(1,3);

    ?>
    <img src="00<?=$img?>a.jpg" />
    <img src="00<?=$img?>b.jpg" />
    <img src="00<?=$img?>c.jpg" />

    <?
    that should work too shouldn't it???

    also from the php manual
    http://www.php.net/manual/en/function.rand.php

    Greets

    Peanuts
    Last edited by peanuts; Feb 5, 2002 at 04:19.
    the neigbours (free) WIFI makes it just a little more fun

  6. #6
    SitePoint Addict AbelaJohnB's Avatar
    Join Date
    Oct 2001
    Location
    Eureka, CA. USA
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys,


    I should have remembered this one!





    Later.
    John B. Abela
    www.JohnAbela.Com

  7. #7
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You keep forgetting to seed randomizer, peanuts:
    PHP Code:
    srand((float)microtime()*1000000); 

  8. #8
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by FireFly
    You keep forgetting to seed randomizer, peanuts
    You don't need to with shuffle()

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  9. #9
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey it's new to me too

    so...

    PHP Code:
    srand((float)microtime()*1000000);
    $img = rand(1,3);

    ?>
    <img src="00<?=$img?>a.jpg" />
    <img src="00<?=$img?>b.jpg" />
    <img src="00<?=$img?>c.jpg" />

    <?
    Should do it ???
    the neigbours (free) WIFI makes it just a little more fun

  10. #10
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by seanf
    You don't need to with shuffle()
    I really don't know, but the manual thinks otherwise:
    You must use srand() to seed this function.

  11. #11
    SitePoint Addict AbelaJohnB's Avatar
    Join Date
    Oct 2001
    Location
    Eureka, CA. USA
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about:


    PHP Code:
    <?php
    $numbers 
    range (1,10);
    srand ((double)microtime()*1000000);
    shuffle ($numbers);
    $img $numbers[0];
    ?>

    ??
    John B. Abela
    www.JohnAbela.Com

  12. #12
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I like peanuts' code:
    PHP Code:
    <?php
    srand 
    ((float)microtime()*1000000);
    $img rand(1,3);
    ?>

  13. #13
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by FireFly
    I like peanuts' code:
    PHP Code:
    <?php
    srand 
    ((float)microtime()*1000000);
    $img rand(1,3);
    ?>


    It was kind of a question But hey come to think of it I like it too
    the neigbours (free) WIFI makes it just a little more fun

  14. #14
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by AbelaJohnB
    How about:


    PHP Code:
    <?php
    $numbers 
    range (1,10);
    srand ((double)microtime()*1000000);
    shuffle ($numbers);
    $img $numbers[0];
    ?>

    ??
    If you want it 1 untill 10 (including 10) you can put
    PHP Code:
    srand ((float)microtime()*1000000);
    $img rand(1,10); 
    the neigbours (free) WIFI makes it just a little more fun

  15. #15
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whats the difference between

    (double)microtime
    or
    (float)microtime


    ???
    the neigbours (free) WIFI makes it just a little more fun

  16. #16
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by peanuts
    whats the difference between

    (double)microtime
    or
    (float)microtime


    ???
    nothing. float is a synonym for double.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


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
  •