我有一个显示不同会议名称的下拉列表。我可以选择某个会议,但是当我选择会议时,我希望能够单击提交按钮,以便我可以获得所选会议的变量。
我是数据库的新手,但我尝试添加一个表单,但我似乎无法让它在 PHP 代码中工作。数据库连接并显示所有会议都很好,我只是不知道如何获得等于所选选项的变量。表单已提交,但我没有任何价值。我查遍了整个网络,但一无所获。
.error {
color: #FF0000;
}
<!DOCTYPE HTML>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css" />
</head>
<body>
<form action="" name="selection" method="post">
<select project="ConferenceList" id="ConferenceList" name="ConferenceList">
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php
//Declare variables
$db_host = "";
$db_username = "";
$db_pass = "";
$db_name = "";
//$db_table = "";
//Connect to phpMyAdmin
$con=mysqli_connect("$db_host","$db_username","$db_pass","$db_name");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_select_db($con,"$db_name") or die ("No database");
$result=mysqli_query($con,"select * From conferenceList");
echo "<select id='searchddl'>";
echo "<option> -- Search Conference Name -- </option>";
while($row=mysqli_fetch_array($result))
{
echo "<option>$row[name]</option>";
}
echo "</select>";
//Close phpMyAdmin
mysqli_close($con);
?>
<script>
$( "#searchddl" ).chosen()
</script>
<?php
echo $db_table;
?>
</body>
</html>
慕运维8079593