At the moment I have a dropdown menu. This dropdown menu will display one column of data of my database. This works fine for me.
However, I want achieve this functionality: when the user clicks one option in the dropdown menu the page will give the user a phrase containing the option he clicked, like this "You choose [the option he clicked]!".
What should I do to achieve this?
This is my dropdown menu code:
<!DOCTYPE html>
<html>
<head>
<style>
.dropbtn {
background-color: #3D85C6;
color: white;
font-family: sans-serif;
font-weight: bold;
font-size: 18px;
padding: 18px;
border: none;
cursor: pointer; }
.dropdown {
position: left;
display: inline-block; }
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); }
.dropdown-content a {
color: black;
font-family: sans-serif;
padding: 12px 16px;
text-decoration: none;
display: block; }
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block; }
.dropdown:hover .dropbtn {
background-color: #3D85C6; }
</style>
</head>
<body>
<div class="dropdown">
<button class="dropbtn">Orgnazitions</button>
<div class="dropdown-content">
<?php
$db = new mysqli('localhost:8889', 'root', 'root', 'VBS');
if($db->connect_errno > 0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "SELECT * FROM Orgnazition";
if (!$result = $db->query($sql)){
die('There was an error running the query [' . $db->error . ']');
}
while ($row = $result->fetch_assoc()) {
echo "<a href='choose.php'>".$row['OrgName']."</a>";
} ?>
</div>
</div>
</body>
</html>