I need a bit of help...

A

Anonymous

Guest
Ok, I'm just getting used to PHP. How would I have it so that the page displays 4 links. Each link will be a different colour. If someone presses blue, it follows the command in the PHP, to load the page but with my designated blue images. And if someone presses yellow they get the yellow images, and so on and so forth. I know it can be done all in one php file. I know it requires if staments. I'm just not quite comfortable with php format and commands. Thanks :D
 
the only way to get comfortable with php is to use and practice it... or pick up a good book, and read it if you havent done so yet. In my opinion its quite useless to dabble in something you are not willing to practice... :wink:
 
I am trying to use it. Can anyone tell me how to do the above?
 
You could have the links pointing to the page, but with a GET parameter, i.e. myscript.php?colour=blue then on the myscript.php page, you can have something like this.

Code:
if (isset($_GET['colour'])){

$colour = $_GET['colour'];
}
else{
//if the link hasn't been clicked, default to blue
$colour = "blue";
}

Then simply add $colour to the front of all your images, for example
Code:
print "<img src=\"{$colour}header.gif\">

Then make all your images.. e.g blueheader.gif, greenheader.gif, yellowheader.gif

There might be an easier way, but this the best I can think of on the spot.
 
Back
Top