PHP代码以选择HTML中的select控件的值 [英] PHP code to select a value of a select control in HTML

查看:129
本文介绍了PHP代码以选择HTML中的select控件的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似html的控件.

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>



现在通过PHP将数据存储在MYSQL中.
现在在检索时,我执行一个查询.

像这样



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))
{
 //please help me here to select the above control's value
}



数据库只能存储VEG,非VEG或Eggiterian值.
在检索过程中,应选择查询结果中存在的值.

请帮帮我.

我想通过查询结果的值选择组合框的值.



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

推荐答案

qry = " .


id;


res = mysql_query(
res=mysql_query(


这篇关于PHP代码以选择HTML中的select控件的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆