I have this dropdown list that shows the name of different conferences. I can select a certain conference, but as I select the conference, I want to add a submit button so I can get a variable for the conference that was selected.
I'm new with databases, but I have tried adding a form, but I can't seem to get it to work inside of the php code. The database connects and shows all of the conferences just fine, I just can't figure out how to get a variable equal to the selected option.
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?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 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" />
<script>
$("#searchddl").chosen();
</script>
</body>
</html>
I expected a variable to equal the same thing that is selected. So I want my variable to equal whatever this is echo "<option>$row[name]</option>";
enter image description here