Suggestions for simple random image script

Would like to randomly display one of five new JPG banner each time page is loaded.
Your experience would be appreciated.
Thanks

Since no one replied, I am posting solution I found.for future inquiries.
Simple PHP Random Image Script
This can be done in one line of text directly in your HTML and a collection of images.
The first step is to gather together the images you wish to have randomly rotated.
Change all of their file names to a numerical order, starting with the number 1.
    * 1.jpg
    * 2.jpg
    * 3.jpg
    * 4.jpg
Be sure each image has the same extension (either all jpg, png, or gif),
and that there are no gaps in the numbers.
Also, place these images in their own folder to keep everything organized.
Write the Code
In the HTML of your page, insert the following code where you want an image to display:
<img src="path/<?php echo rand(1,n);?>.jpg" alt="Random Image" />
The “rand” operator will display a randomly generated number between 1 and ‘n’.
Change ‘n’ to the total amount of pictures you have arranged numerically
(or the highest numbered picture you have).
In the example above I only have 4 pictures, therefor I would change it to: rand(1,4);

Similar Messages

  • Choose random image script

    I'm creating a small movie with a set of random images that all appear in the same spot (no horizontal or vertical movement). I want each image to appear onscreen for two seconds, then be replaced by another randomly-chosen image. There are 17 images in the set. Here is the script I'm using:
    on enterFrame
      channel=random(17)
      _movie.delay(2*60)
    on exitFrame
      go to the Frame
    end
    This script works well. However, because the population is small - only 17 - what happens when I run the script is that a little too often it randomly chooses the same image once, twice, sometimes up to five times in a row, which gives the effect that the movie is either stuck or not working properly. I would like to find out how to modify the script so that on exitFrame it chooses randomly any of the other 16 images but not the current image. At first I thought if the script read random(16) or random(17-1) that might work, but it doesn't.
    Any thoughts would be welcome.
    Dallas

    Hi Sean,
    This randomizing project of mine is becoming more complex than I first realized and I now have another question that I hope you might be able to help me with.
    The project breaks down into class, category, group and member. There are 9 classes (and perhaps a possibility in the future that further classes could be added). The structure and naming convention within each class is identical down to the member level. For example, Cat. 1 of Class 2 and Cat 1 of Class 7 both have the same names. Group 3 of Cat. 1 of Class 2 and Group 3 of Cat 1 of Class 6 both have the same names. However, the members of these groups do not have the same names.
    In each class there are 4 categories, each with a different name. Each category contains a number of groups (each group has a different name). Each group contains a number of members. Each member in categories 1 and 2 is a bitmap image. The total number of bitmap members in the project is 21.
    To give a fictionalized example (this project is not about clothing, but I'm using it as an example):
    Class 1 = shirts
    Class 2 = hats
    Class 3 = pants
    Class 4 = socks
    Class 5 = shoes
    etc.
    Category 1 = British
    Category 2 = Japanese
    Category 3 = Turkish
    Category 4 = Brazilian
    Group 1 = Cotton
    Group 2 = Synthetic
    Group 3 = Speed
    Group 4 = Sound
    and so forth.
    In Class 1 (shirts) there are British, Japanese, Turkish and Brazilian shirts and these could be made of either cotton or synthetic. In addition, there are a variety of speeds and sounds from which to choose when displaying the shirts.
    In my project:
    Cat. 1 has 7 groups and each group varies in the number of members with either 7, 14 or 21 (but no other alternative to these numbers).
    Cat. 2 has 13 groups and each group has 7 members.
    Cat. 3 does not randomize images but lets me choose any one of 12 different speeds for randomization in half-second increments.
    Cat. 4 does not randomize images but lets me choose any one of 6 different sounds. Whenever the randomized image changes, this triggers the sound. The sound is not randomized but is consistent once the choice for what KIND of sound has been made. In short: tick, tick,tick, or tock, tock, tock but not tick, tock. It is possible that in the future more sounds could be added.
    Navigation should allow me to start with any of the four categories. For randomization to work, I must choose within either Cat. 1 or Cat. 2 (but not both) and I must make a choice of some sort within Cat. 3 (speed of randomization) while Cat. 4 is entirely optional (sound on or off, but not required to be on and, if it's to be on then choice for which kind of sound).
    There are also an additional two buttons for sound on or off than run the length of the score within any class, meaning that while randomization is occuring anywhere within a class, I can choose to turn the sound on if it's currently off or off if it's currently on. Turning it on while randomization is taking place will also probably require a choice of which kind of sound (meaning a floating window I suppose) so as not to exit the frame where randomization is taking place.
    Now for my question: should I create one massive behaviour script for all classes that includes a series of nested if/else statements for each category, group and member, or should I create 4 large behavior scripts, one for each category with if/else instructions for its groups and members, or should I script at the group level, which will result in 180 separate behaviour scripts for image randomization plus additional scripts for speed and sound?
    Further, I understand how to apply at the group level the script you gave me earlier (and it works beautifully), but if you think it would be more efficient now to work at the category or class level, I'm not sure how to script the if/else statements. I'm assuming that in whichever of these solutions turns out to be best, it is applied to a single sprite which will serve to display the randomly-chosen image. Bear in mind that the script you gave me randomizes the image change every two seconds. Now I'm looking to have a choice of it changing within a range of once every half-second to once every 5 seconds (e.g. 0.5 sceonds, 1 second, 1.5 seconds, 2 seconds, etc.).
    An ancillary question: could this be done a different way? A friend suggested using subroutines but wasn't able to tell me how to do this because he doesn't know anything about Lingo. I was wondering whether the if/then syntax structure is Lingo's way of doing subroutines.
    Your thoughts would be most welcome. If you think you can't help me with this, do you have any suggestions as to where I might turn for help (apart from the nuthouse at this point)?
    Cheers,
    Dallas

  • Looking for a random image extension

    Does anybody know of a good FREE extension that will put a
    random image inside a cell of a table?
    I'm actually looking to do two different things. The first: I
    want a random image from about 10 images to change every time the
    user reloads the page. The second: I want images from about 10
    images to fade up, stay on the page for a few seconds, then fade
    down and have another one of the 10 fade up, so on and so forth.
    If anyone knows of a free extension that will do this, I
    would love to know about it, thanks!

    This one works fine for me,
    * Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (
    http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit
    http://www.dynamicdrive.com/
    for this script and 100s more.
    hth

  • Need Random Image Script with Links

    I am needing a script for random images on my homepage. I
    need the image to have its own link depending on what image is
    displayed. I would like a php script (non database) if
    possible

    See comments on DW forum about random includes and this
    particular markup
    shown below.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "newhorizonhosting.com" <[email protected]>
    wrote in message
    news:e29on1$buf$[email protected]..
    >I figured it out by doing a random include
    >
    > <?
    > srand(time());
    > $random = (rand()%3);
    > print("$random");
    > require_once("./$random.php");
    > ?>

  • Need Random Image Script with Link

    I am needing a script for random images on my homepage. I
    need the image to have its own link depending on what image is
    displayed. I would like a php script (non database) if
    possible

    Not sure about the PHP but there are some good scrips on
    www.kaosweaver.com
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "newhorizonhosting.com" <[email protected]>
    wrote in message
    news:e28rpm$8is$[email protected]..
    >I am needing a script for random images on my homepage. I
    need the image to
    >have its own link depending on what image is displayed. I
    would like a php
    >script (non database) if possible

  • A random image script

    hi all :)
    i want to create a random card picker and this script works great for me. but how can i add clickable links to cards after they are generated randomly? i want the new image generated in the same place where 0.jpg is when button is clicked exactly like in the script, but with a clickable link on it.
    thanks in advance :)
    <script language="javascript">
    <!-- Begin
    function show(){
    var theImages = new Array()
    theImages[0] = 'deck/card1.jpg'
    theImages[1] = 'deck/card2.jpg'
    theImages[2] = 'deck/card3.jpg'
    theImages[3] = 'deck/card4.jpg'
    theImages[4] = 'deck/card5.jpg'
    theImages[5] = 'deck/card6.jpg'
    var j = 0
    var p = theImages.length;
    var preBuffer = new Array()
    for (i = 0; i < p; i++){
    preBuffer[i] = new Image()
    preBuffer.src = theImages[i]
    var whichImage = Math.round(Math.random()*(p-1));
    document.picture.src = theImages[whichImage];
    }// End -->
    </script>
    <img src="deck/0.jpg" name="picture" />
    <form>
    <input type="button" value="pick a card" onclick="show()">
    </form>

    Java is not the same as JavaScript.
    Try posting your question in a [JavaScript forum|http://www.google.com/search?q=javascript+forum].

  • Comments/Suggestions for Simple Game?

    I have a super simple game I made. You can download it here:
    http://www.filedropper.com/catchphrase2
    Anybody have suggestions/ideas?

    TokyoTony wrote:
    I'd like to try something else please. The reason is as follows:
    When I put in a name for the document and then scan the documents, the file still comes up as untitled. I don't get that.
    When I want to rotate a page that is supposed to be landscape and do the rotation in Image Capture, all it does is cut the top and bottom out--it rotates the selection, not the image. I know I can do this in a PDF editor but why not have everything I need done in one application?
    When I do want to select A4 size, I don't see it unless I hide details. Seems a bit strange.
    Thanks,
    Tony
    Are you scanning into a program, or to a file? Either way, it seems to work for me with Preview. I didn’t try another app.
    I can’t replicate your other problems, either. Rotation works as expected and I have both Letter and A4 available on both interfaces.
    I have an Epson all-in-one, though.
    Perhaps if you listed your HP model number, others with that same printer/scanner could help.
    One thing to try, though. Log into another user on the Mac and try to scan. Same results?
    Boot into Safe Mode and try to scan. Same results?
    OS X: What is Safe Boot, Safe Mode?
    Those two steps will see if the problem is system-wide or caused by some additional software you have running at startup.

  • Looking for simple auth Tcl script

    I just need a simple Tcl script (service) that when applied to a dial-peer will send a radius auth using a User-Name and Password supplied to it as parameters.
    Anyone have one lying around or could whip one up?
    Thanks in advance,
    Roman.

    hi,
    the script as you say is embeddded in all voice images, do show call application voice summary to see a list, and show call application voice to see them all.
    Hope this helps, please rate post if it does!

  • I'm looking for a random quote script for my website?

    So I've got a very large numbered list of quotes. I want to set up a  little text thing on my website's homepage so it displays a randomly  selected quote from the list which changes every day. Can anyone write  me a script to do this? I had one, but it stopped working and no one's  been able to help me fix it (I've tried to get help with that more times  than I care to remember) and I decided that it would be better to just  get a new script.

    I have a random script, but it also seems to not be working the way it was originally written, it now outputs a number 1  along with the intended output.
    Take a peek here, there is a rotator script I am about to use on a site I am workng on.
    http://www.marcofolio.net/
    Gary

  • 160 MB for simple EPS image

    I used R to create an PDF file containing a simple plot. I loaded the pdf into Illustrator and attempted to save it out to EPS. The eps version of the file is ~160MB. It should be about 2.
    Any idea what is going on here?
    Thanks,
    Dale

    What is R?
    Illustrator is not a PDF editor, except from PDFs created in Illustrator with Illustrator's edibility turned on. So it will cause a problem.
    Do you need EPS?

  • Random Image PHP Scipt Issue

    I am using a
    PHP random image
    script on a site in which I have 2 different images on each
    templated page (random images throgh a site). The two images call
    to 2 different folders with the random image script in them (to get
    2 distinct images). Thus, 2 different random images. My issue is
    that it seems that most browsers at some point do not call for a
    new image but use what was there in the last page as it is the same
    name:
    http://ansano.com/asl/images/random/top/random_image.php
    or
    http://ansano.com/asl/images/random/bottom/random_image.php
    Any idea of how to force a browser to call the PHP script? Or
    how to change it so it works site wide?
    Thanks!!

    I've now been sitting looking for this for a while. I don't seem to be able to get it to work.
    Do I need to host to a folder first and then to the FTP server after?
    I don't seen to be able to find the new page (TEST PAGE) in the folder I used to publish the site to before I went online. Tried searching for it in finder but I don't get any results on (TESTPAGEfiles).
    I can see what you are talking bout I only publish to a local folder but I want to publish via the FTP option in iWeb.
    Thank you very much for helping me

  • Suggestions for routine maintenance?

    My daugter is heading off to college with a new 15" MBP. Any suggestions for simple, regular maintenace she could do?

    To be honest, Macs don't need much maintenance. There are scripts scheduled to run in the middle of the night which don't run if the machine is off. Some people like to run these manually using a utility like macjanitor.
    Personally I prefer anacron - it runs the scripts automatically if missed.
    http://members.cox.net/18james/anacron-tiger.html
    SO download and install that.
    Other than that, run software update regularly.
    And...when updating software, run repair disk permissions, from the disk utility in applications/utilities - I keep it on the dock.
    Can't think of anything else worth doing as regular maintenance.
    Best of luck.

  • Random Image not displaying in Live View.

    My page is at:
    www.andrewjamesartist.co.uk
    There's a random image script on the front page.
    <img src="randomimages/rotate.php" alt="A Sample Image from the work of Andrew James" />
    That's how it is placed in the page.
    It shows in preview in browser and it's OK live but it doesn't show in LiveView.
    I use a testing server set up with virtual hosts.
    Martin

    My page is at:
    www.andrewjamesartist.co.uk
    There's a random image script on the front page.
    <img src="randomimages/rotate.php" alt="A Sample Image from the work of Andrew James" />
    That's how it is placed in the page.
    It shows in preview in browser and it's OK live but it doesn't show in LiveView.
    I use a testing server set up with virtual hosts.
    Martin

  • Any Suggestions for CGI Script for Web Slide Slow?

    Do you have any suggestions for creating a slideshow for my web site, 6 same-size jpgs that rotate automatically?
    I think I prefer a cgi script. However, I've tried two that don't work on Firefox or Safari. One developer tells me that he can see the rotating photos.
    I'm also open to software to create this. However, I'd prefer to use html code.
    Of course, it must work cross platform.
    Any suggestions?
    G5 Quad; Mini Mac; PowerBook G3; iPods   Mac OS X (10.4.8)   Using Dreamweaver 8

    Oh, what a beautiful baby! Is he/she yours?
    She is mine. At least that's what the Mrs. tells me!
    When you say gif, I am assuming that you mean the
    format really must be gif and not jpg. Is that
    correct?
    Yes, the file is a GIF file. It's actually an animated GIF file, meaning that the images that you see are all frames of animation in a single GIF file. There are a lot of apps out there that can create animated GIFs. I happen to use Adobe ImageReady because that is what is on the hard drive.
    Can you give me a hint about the dithering issue? Do
    I dither or not dither, that is the question.
    This is the major downside of the GIF format. It is a really old format...from back in the CompuServe bulletin board days...maybe older. Anyways, it is my understanding that GIFs can only hold information for 256 colors....any 256 colors, but no more and no less. So now in the days of "millions of colors" jpegs, you can imagine that a 256 color palette is limiting. But if the colors of your images are sufficiently close, its possible that 256 colors makes for perfectly acceptable images across all images. This is the one variable of converting images to GIF that can make it or break it for you. If your image has a pretty broad tonal range...like fleshtones or any other gradient...then 256 colors is going to represent things poorly. Then you will get dithering artifacts which is like averaging errors...colors are close...as close as possible...but not close enough to make a smooth gradation. Anyways, that's my layperson's understanding.
    But for some images, it looks just fine.

  • Simple upload image to amazon S3 winjs for windows phone 8.1?

    Hi
    Can behind simple upload image to amazon S3 winjs for windows phone 8.1?Thank

    Yes.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

Maybe you are looking for

  • Icloud problem with Keynote

    My keynote presentation would upload to iCloud.  I have Keynote on my iPhone and Keynote (v. 5.20) on my MacBook Pro.  I'm running OS X Mountain Lion 10.8.2.  I dragged the presentation to the iCloud box and I see a "waiting" message underneath.

  • Starting logminer from java

    I want to start logminer tool from java To start logminer tool the first step is alter system set utl_file_dir='C:\oracle\product\10.2.0\logminer_dir' scope=spfile; shutdown immediate startup I am working on eclipse The alter command is executed, but

  • Using dual display with DVD Player

    I like to use the dual screen mode in my lectures using Keynote. Occasionally, I like to include a short DVD in my lectures. Is there a way to set DVD Player so that it plays in the dual screen mode so that I don't have to switch to the mirror screen

  • How to show the User Name on the Cart.aspx page when a user is connected.

    Hi, I am trying to find how I can get the User Name and display it in the top of the Cart.aspx. For the diplay point of view, this is fine (I have created a <Literal> with a property ID, and specified it in the prerender.) However, i can not find any

  • Install RAW DNG Converter 7-2 from my desktop to Bridge and Photoshop?

    I have a Sony A99 DSLR which is now supported by Adobe.  I downloaded the DNG (RAW) Converter 7_2 to my desktop.  How do I install it in Bridge and Photoshop?