Page 1 of 1

Help creating a php code

Posted: Fri Sep 12, 2008 2:15 pm
by shadow007
Ok heres basically what I want to do. I want to update a specific image. basically I want to in my admin panel that I have, have a drop down box. and in that drop down box there are 5 things. Level 1,Level 2,Level 3,Level 4,Level 5.

Basically this.

<option>Level 1</option>
<option>Level 2</option>
<option>Level 3</option>
<option>Level 4</option>
<option>Level 5</option>


then what I want it to do is on the main page, (i.e. index.php)
I want it to change to the picture thats assigned to that option. Basicaly there a small graphic thats in a specific area (whever its placed) and when the option is updated in the admin panel it changes to the assigned picuture.

example of assigned pic

<option>Level 1</option> level1.png
<option>Level 2</option> level2.png
<option>Level 3</option> level3.png
<option>Level 4</option> level4.png
<option>Level 5</option> level5.png

and of course it would haev to be related to a mysql field and the table row would be called
slvl

Re: Help creating a php code

Posted: Fri Sep 12, 2008 2:54 pm
by deejay
I think what your trying to get at is making the <form> that you have your dropdown list in send to the same page ie $PHP_SELF -

Then you'll have the result of your form stored in $_POST - which you'll then need to write a bit of code which reacts to which ever result is given ie.

Code: Select all

 
 
if ($_POST['img1']){
echo '<img src="img1.jpg">';
}
elseif($_POST['img2']){
echo '<img src="img2.jpg">';
}
 
 
Hope that helps

Re: Help creating a php code

Posted: Fri Sep 12, 2008 4:07 pm
by jfeaz
What is the name of your <select> tag?

ie <select name="?">