Page 1 of 1

How to get output value using $_REQUEST

Posted: Tue Sep 06, 2005 5:21 am
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.

Posted: Tue Sep 06, 2005 5:31 am
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?

Posted: Tue Sep 06, 2005 5:48 am
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>