Dynamic Select Box

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
User avatar
ankurdave
Forum Newbie
Posts: 7
Joined: Tue May 18, 2004 12:35 am
Location: INDIA

Dynamic Select Box

Post by ankurdave »

Dear Friends

I have a simple problem that i haev a select box in which 5 values 1,2,3,4,5 and the formation is

Code: Select all

<option>Select Rank</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
so wheh i select the rank so the query is fired for the selected rank. and result is displayed in the same page because the action is

Code: Select all

$PHP_SELF
the result is shown to me but in select box i always get the first line "select Rank" and i want it display the selected value in the select box and will changE when i refresh it or change it for the next query.

Because currently it is looking odd that the value is not shown in the select box and query is fired.

Please Help Me
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use something similar to:

Code: Select all

<option<?= ((isset($_REQUEST['rank']) && $_REQUEST['rank'] == 2)?" selected":"") ?>>2</option>
Post Reply