How to get output value using $_REQUEST

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
amlan_08
Forum Newbie
Posts: 11
Joined: Sun May 22, 2005 1:24 am

How to get output value using $_REQUEST

Post by amlan_08 »

In my template in have an select structure like

Code: Select all

<select name="status">
     <option value=1>Yes</option>
     <option value=2>No</option>
</select>
But when the page submitted & I try to get the status value with $_REQUEST['status'], it shows 1 if I choose Yes & 2 in other case. How can I get the output value in $_REQUEST. I can't change the option value in string. Also can't use if/else statements to get that output value. Plz help me.
skhale
Forum Newbie
Posts: 6
Joined: Sat Aug 06, 2005 12:56 pm
Location: Boston, MA

Post by skhale »

You could make an array if you really have to

Code: Select all

$status_options = array(
        'Yes',
        'No'
    );
and then use the value to select a member of the array

Code: Select all

echo $status_options[$_REQUEST['status']];
Are you sure you can't use if/else statments?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

why don't you go the normal way i.e. having value you require put as value attribute :?:
o_O

Code: Select all

<select name="status"> 
<option value="Yes">Yes</option> 
<option value="No">No</option> 
</select>
Post Reply