ciaranajl Posted September 22, 2006 Share Posted September 22, 2006 I am trying to make a random image generator for my website, mugglenet.com. I have several different images, representing several differents sections of my site. But I want each image, when it appears, to LINK to the relevant section of the site. Here is the coding I came up with so far - would be grateful if someone could set me right![code]<? $imagevar=rand(1, 6); if($imagevar==1) { print "<a href="/books/futurebooks/book7/index.shtml'><img src='/layouts/advertisements/book.gif' style="border: 0px" /></a>"; } else if($imagevar==2) { print "<a href='/editorials/'><img src='/layouts/advertisements/edit.gif' style='border: 0px' /></a>"; } else if($imagevar==3) { print "<a href='/infosection/'><img src='/layouts/advertisements/ency.gif' style='border: 0px' /></a>"; } else if($imagevar==4) { print "<a href='http://fanfiction.mugglenet.com'><img src='/layouts/advertisements/ff.gif' style='border: 0px' /></a>"; } else if($imagevar==5) { print "<a href='/movies/movie5/'><img src='/layouts/advertisements/film.gif' style='border: 0px' /></a>"; } else if($imagevar==6) { print "<a href='/gallery'><img src='/layouts/advertisements/gallery.gif' style='border: 0px' /></a>"; ?>[/code] Quote Link to comment Share on other sites More sharing options...
AdRock Posted September 22, 2006 Share Posted September 22, 2006 would a switch statement work any better/more efficiently? Quote Link to comment Share on other sites More sharing options...
ciaranajl Posted September 22, 2006 Author Share Posted September 22, 2006 "Switch stament"? I'm really not experience at all in PHP, so if this is a PHP term, I've no idea what it is... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.