I have a UL lists being created dynamically from MySQL. When I select one of the items I would like to have it submit that value into a different table. So I guess I would like to turn the list itself into a form. (not sure if that's the correct thinking though).
<?php include_once "Connections/myDatabase.php"; ?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
.selectable {
display: list-item;
height: 30px;
width: 300px;
list-style-type: none;
cursor: pointer;
filter: Light;
}
</style>
</head>
<body>
<ul style="list-style-type:none">
<?php
$sql = "SELECT client_name FROM clients";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<li class='selectable'> " . $row["client_name"]. "</li>";
}
} else {
echo "0 results";
}
$conn->close();
?>
</ul>
</body>
</html>
You can get it if you use and in html, because you can get value from option on change.
<select name="list">
<option value='1'> item one </option>
</select>
Post it with a Form, and take it with $_POST["list"].
:-)