SEO Services
Home >> Webmaster Forums >> Random Images in header

Random Images in header


markGFC said: "I would like my header graphic to display a different header at random each time a different page is visited. Can anybody tell me if they know of a simple php script that can do this for me? I have about a dozen header graphics of a fixed size to use."

Sharky said: "i would use the random function it would go something like this [code] $random = rand(1,5); if (random == "1") $showpicture = "\"my"; if (random == "2") $showpicture = "\"my"; if (random == "3") $showpicture = "\"my"; if (random == "4") $showpicture = "\"my"; if (random == "5") $showpicture = "\"my"; echo "$showpicture"; [/code]"

Neutron2k said: "sharky thats bad coding. you should be using if... elseif statements. not just a set of if statements."

Sharky said: "[code]$random = rand(1,5); if (random == "1") $showpicture = "\"my"; else if (random == "2") $showpicture = "\"my"; else if (random == "3") $showpicture = "\"my"; else if (random == "4") $showpicture = "\"my"; else if (random == "5") $showpicture = "\"my"; echo "$showpicture";[/code] u mean like that? anyway i thought that was pritty good for me :D and ive started reading my php book, but im piled over with course work so i havent got much chance to read it :("

Neutron2k said: "no elseif is one statement in php if (condition) { } elseif(condition) {} elseif(condition) {} else {}"

Sharky said: "o right, i havent really found any uses for if else statement so i havent learned it :D"

Neutron2k said: "you will. its essential programming principles. for starters, the way you coded it, the interpreter has to go through and execute that same if statements god knows how many times, regardless of it it previously was executed. using the rest of the conditional statements ensure that the correct code gets executed and the rest is ignored."

edwin said: "so what is a good function, n2k?"

Neutron2k said: "in what way do you mean a good function edwin dude? whats the best way to code a function? what is a good in built function? :confused: me lost!"