PHP代码以选择HTML中的select控件的值

编程入门 行业动态 更新时间:2024-10-15 20:25:33
本文介绍了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 =".

id;

res = mysql_query( res=mysql_query(

更多推荐

PHP代码以选择HTML中的select控件的值

本文发布于:2023-11-06 08:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563146.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   代码   PHP   select   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!