我想显示一个下拉列表,其中包含从只有一列的表中检索到的数据 p> \ n
这是我的表格 p>
< html>
< head>
< / head>
< body>
&lt ; form action =“insert_customer_complaint.php”method =“post”>
名称:< input type =“text”name =“name”>< br>
Complaint:< input type =“text “name =”comp“>< br>
Reason:< select name =”reason“>
Add< input type =”submit“>
< / form>
< / body>
< / html>
code> pre>
这个用于插入数据的php文件 p>
&lt ;?php
//创建连接
$ con = mysqli_connect(“localhost”,“ccc”,“ccc”,“ccc”);
//检查连接
if(mysqli_connect_errno())
{
echo“无法连接到MySQL:”。 mysqli_connect_error();
}
$ sql =“INSERT INTO reason(reason_name)
VALUES
('$ _ POST [reason_name]')”;
if(!mysqli_query($ con,$) sql))
{
die('错误:'。mysqli_error($ con));
}
echo“添加了1条记录”;
mysqli_close($ con);
?n  \ n code> pre>
插入部分非常有效我需要使用相同的php文件从一个表中获取下拉列表的数据 p>
\ n
表名=原因,列名= reason_name p>
请帮帮我 p>
我已经插入数据并且每件事情都运作良好 。 现在我想在一个表格中生成报告,从中应该从特定行的数据中检索列名称这里是我需要的 p>
请参阅点击图片 p>
http://testserverforprojects.tk/CC/tables.JPG < / p>
表应该是动态的,因为它应该在最后一年结束,例如今年只有2013年的数据,所以2013年将是最后一列..所以在2015年,2014年将是 最后一栏 p>
div>