从数据库中检索数据并以下拉格式显示。并使用相同的下拉列表作为输入。 [英] Retrieve data from database and display it in drop down format. And use the same drop down list as an input.

查看:92
本文介绍了从数据库中检索数据并以下拉格式显示。并使用相同的下拉列表作为输入。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以下问题。我能够从数据库中检索数据并将其显示在下拉菜单中。但我不知道如何使用相同的下拉列表作为输入并将其嵌入到表单中我的代码如下。这些项目名称是从数据库中检索出来的,并以下拉列表的形式显示。现在我需要在表格(HTML表格)中使用相同的下拉列表,用于输入数据到另一张桌子。







i have been having the following problem .I am able to retrieve the data from database and display it in a drop down menu.But i dont know how to use the same drop down list as the input and embed it in a form.My code is as follows.Here project names are retrieved from the database and are displayed in the form of drop down list.Now i need to use the same drop down list in the form(HTML form) which will be used to input data into another table.



<html>
<head></head>
<body>
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
include 'connect.php' ;
$tbl_name="projects";


$sql="SELECT project_name FROM $tbl_name ";

$result=mysql_query($sql);


if($result === FALSE) {
die(mysql_error());  
}
?>


<form name="resources" action="hourssubmit.php"  method="post" >

<?php
echo "<select name='project_name'>";
while ($row = mysql_fetch_array($result)) {

echo "<option value='" . $row['project_name'] ."'>" . $row['project_name']."</option>";
}
echo "</select>";
?>

</form>
</body>
</html>

推荐答案

tbl_name =projects;
tbl_name="projects";


sql =SELECT project_name FROM
sql="SELECT project_name FROM


tbl_name;
tbl_name ";


这篇关于从数据库中检索数据并以下拉格式显示。并使用相同的下拉列表作为输入。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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