Jump to content


HELP! Random LINKING image generator

  • Please log in to reply
2 replies to this topic

#1 ciaranajl

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 September 2006 - 04:13 PM

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!

<? $imagevar=rand(1, 6); if($imagevar==1) { print "<a 


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>"; ?>

#2 AdRock

  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 22 September 2006 - 04:53 PM

would a switch statement work any better/more efficiently?
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#3 ciaranajl

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 September 2006 - 04:55 PM

"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...

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users