Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Random Images...

  • 07-08-2007 08:52PM
    #1
    Registered Users, Registered Users 2 Posts: 16,624 ✭✭✭✭


    I really need help... Heh.

    Bet you didn't see that one coming.

    Right - On my homepage, I have a series of different images with my logo on top. I'm not great with coding, but would know a wee bit. I'm really stuck however, on the fact that I want the image on the main page to be different with each refresh - I've tried flash & don't like the load up time much.

    If anyone could offer a link, some advice, anything, it would be greatly appreciated...

    Thanks in advance!


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Depends on what you're using.....PHP can do this itself, automatically getting a list of images in a directory and displaying the image source for a random one.

    You can also set a JavaScript array, explicitly setting the filenames of the images, and then get a random number and use that array element.

    But it definitely depends on what you're using.


  • Registered Users, Registered Users 2 Posts: 16,624 ✭✭✭✭Fajitas!


    Well, so far all is in HTML, and have a random image generator using Javascript (which was all done by my friend (440hz here) ), but I don't want the images changing at all, until the page is refreshed - http://www.alhigginsphotography.com is the site as is, though I'll be making a revamp of it as soon as I get this working.

    Would you reccomend anything in particular? I've yet to do anything serious with Php


  • Closed Accounts Posts: 7,144 ✭✭✭DonkeyStyle \o/


    <img src="images/image<?php print rand(1,10); ?>.jpg">
    
    Will load a pseudo-random image in the range of 1 to 10 upon page load/refresh.

    So just make:
    /images/image1.jpg
    /images/image2.jpg
    [..]
    /images/image10.jpg

    Easy phpeezee


  • Registered Users, Registered Users 2 Posts: 16,624 ✭✭✭✭Fajitas!


    Lol, thanks!

    :D

    Day off tomorrow, will finish the site!

    Thanks again DonkeyStyle, owe you a pint if yer at the next beers...was going off my head with that one!


  • Closed Accounts Posts: 7,144 ✭✭✭DonkeyStyle \o/


    No worries dude, just make sure to name the page with a .php extension and not .html so the webserver knows to parse the php.


  • Advertisement
  • Closed Accounts Posts: 250 ✭✭GP


    and hope that you have php setup on your server ;-)


Advertisement