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!
well first of all you didn't quite understand the logic :
You are using the same if clause in all options whereas you should actually check if the specific value is the one selected so to be displayed. {if $companyrole=='Contractor', if $companyrole=='Subcontractor' etc}
It is actually very simiral to the input box that you said worked for you but instead, since you have a list of values the select box can obtain, you put an if clause at each option in order to display the one that has the value of the select box.
The value of the select box is obtained by $_REQUEST['companyrole'] , or post or get
<select name='companyrole'>
<option value=''> - Select Company's Role - </option>
<option value='Contractor' <? if (isset($_POST['companyrole'])) echo "selected"; ?>>Contractor</option>
<option value='Sub-Contractor' <? if (isset($_POST['companyrole'])) echo "selected"; ?>>Sub-Contractor</option>
<option value='Outsourcing' <? if (isset($_POST['companyrole'])) echo "selected"; ?>>Outsourcing</option>
</select>
still do not work but instead of posting the " - Select Company's Role - ", the oursourcing is selected...can't understand why because the oursourcing code is the same as the contractor and the sub-contractor...
You are putting 3 valid if statement and as a result the action of the last one is kept so outsourcing is selected. That 's why I said that you need to stand back and understand the logic first.
if(isset($_POST['companyrole'])) is a valid statement, what you need is to get the value of it
<option value='Contractor' <? if ($_POST['companyrole']=='Contractor') echo "selected"; ?>>Contractor</option>
<option value='Sub-Contractor' <? if ($_POST['companyrole']=='Sub-Contractor') echo "selected"; ?>>Contractor</option>
<option value='Outsourcing' <? if ($_POST['companyrole']=='Outsourcing') echo "selected"; ?>>Contractor</option>