PHP

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
leathem
Forum Newbie
Posts: 9
Joined: Tue Sep 02, 2008 3:21 am

PHP

Post by leathem »

Hello all,
Last edited by leathem on Thu Sep 04, 2008 2:24 am, edited 1 time in total.
User avatar
starram
Forum Commoner
Posts: 58
Joined: Thu Apr 10, 2008 1:27 am
Location: India
Contact:

Re: PHP refresh problem:banghead:

Post 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>
Post Reply