php下拉框数据库 php下拉列表

PHP中怎么让一个下拉菜单的内容是从数据库读取出的数据?

首先你要selectnbsp;*nbsp;fromnbsp;albumnbsp;wherenbsp;uid=yourid然后用while循环输出,应该是echo吧sql=“selectnbsp;*nbsp;fromnbsp;albumnbsp;wherenbsp;uid=yourid“输出amp;lt;selectamp;gt;while循环在循环内部输出amp;lt;optionamp;gt;titleamp;lt;/optionamp;gt;输出amp;lt;/selectamp;gt;大概其是这样,你调试下

成都创新互联公司专业成都网站设计、网站制作,集网站策划、网站设计、网站制作于一体,网站seo、网站优化、网站营销、软文平台等专业人才根据搜索规律编程设计,让网站在运行后,在搜索中有好的表现,专业设计制作为您带来效益的网站!让网站建设为您创造效益。

如何用php将数据库中的信息遍历到下拉框选项中

?php

$con = mysql_connect("localhost","root","");//连接数据库

mysql_select_db('test');//选择数据库

?

html

head

titledropdown from mysql/title

/head

body

h1dropdown from mysql/h1

form action="#" method="post"

select

option value=0--请选择--/option

?php

$sql= "select val from custom where field='hook_load'";//sql语句

$result = mysql_query($sql, $con);//执行sql语句

while($row = mysql_fetch_array($result))

{

echo "option value='$row[val]'$row[val]/option";//循环,拼凑下拉框选项

?

/select

/form

/body

/html

php如何把数据库与下拉框联系起来?

要使用AJAX了, 菜单联动就可以了;

参考如下:

?php

//require_once('conn.php');  //写个连接数据库的文件 每次包含一下就行了, 而且要写在最上面。

$con = mysql_connect("localhost","root","***");  

?

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""

html xmlns=""

head

meta http-equiv="Content-Type" content="text/html; charset=gb2312" /

title无标题文档/title

/head

body

select

option-请选择-/option

?php

$sql="select CID from course2";

$result=mysql_query($sql);

while($row=mysql_fetch_assoc($result)){

?

option value="$row['CID']"?php echo $row['CID'] ?/option  //这个值要用php的方法取出来

?php

}

?

/select

/body

/html


网站题目:php下拉框数据库 php下拉列表
路径分享:http://myzitong.com/article/dogpjhc.html