I have a control in html look like this.
<select name='diet' class='inputbox'>
<option value=''>Select one</option>
<option value='VEG' >VEG</option>
<option value='Non-Veg' >Non-Veg</option>
<option value='Eggiterian' >Eggiterian</option>
</select>
Now through PHP I stored the data in MYSQL.
Now at the time of retrieve, I execute a query.
Like this
$qry="SELECT diet FROM tablename where id=" .$id ;
$res=mysql_query($qry);
while($val = mysql_fetch_array($res))
{
}
Database can store only VEG, non-VEG, or Eggiterian value.
at the time of retrieval process it should select the value present in the query result.
Please help me.
I want to select the value of the combo box by the value of my query result.
$qry="SELECT diet FROM tablename where id=" .$id ;
$res=mysql_query($qry);
while($val = mysql_fetch_array($res))
{
echo " <select name='diet' class='inputbox'>
<option value=''>Select one</option>
<option value='VEG' >VEG</option>
<option value='Non-Veg' >Non-Veg</option>
<option value='Eggiterian' >Eggiterian</option>
</select>";
}
I need to select the option of combo box with the value present in my database table. Value will be either veg or non-veg or eggiterian. please help