Page 1 of 1

PHP

Posted: Tue Sep 02, 2008 3:26 am
by leathem
Hello all,

Re: PHP refresh problem:banghead:

Posted: Tue Sep 02, 2008 4:34 am
by starram
Hello,

I didn't understand much about your problem. But what I understood is that you want to keep the drop down value selected which user selected last.

For that you can store the id or value of that option in a session & then implement a check for selected option by matching value of session.

For example. see the below code.

<tr >
<td width="72">SPORT:</td>
<td width="165">
<select name="selectsport">
<option value="">----------Select----------</option>
<?php
////////Getting values from sport table to be displayed in drop down START//////////////////////
$sql_sport_name="select * from tbl_sport";
$result_sport_name=mysql_query($sql_sport_name);
while($value_sport_name=mysql_fetch_assoc($result_sport_name)){
if(isset($sport) && $sport==$value_sport_name['id']){
?>
<option selected="selected" value="<?=$value_sport_name['id']?>"><?=$value_sport_name['title']?></option>
<?php
continue;
}
////////////////////////////////Check for selected state end////////////////////////////////////////////
?>
<option value="<?=$value_sport_name['id']?>"><?=$value_sport_name['title']?></option>
<?php
}
////////Getting values from sport table to be displayed in drop down END//////////////////////
?>
</select>
</td>
<td width="224">&nbsp;</td>
</tr>