Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Random Images...

  • 07-08-2007 7: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,145 ✭✭✭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,145 ✭✭✭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