Help creating a php code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shadow007
Forum Newbie
Posts: 3
Joined: Thu Sep 11, 2008 2:21 pm

Help creating a php code

Post 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
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Re: Help creating a php code

Post 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
jfeaz
Forum Newbie
Posts: 7
Joined: Sat Sep 06, 2008 7:46 pm

Re: Help creating a php code

Post by jfeaz »

What is the name of your <select> tag?

ie <select name="?">
Post Reply