php get dropdown value from database code example
Example 1: get data from database in dropdown list php
<?php
$connect = new mysqli("127.0.0.1","root","");
if ($connect -> connect_errno)
{
echo "Failed to connect to MySQL: " . $connect -> connect_error;
exit();
}
$connect -> select_db("Your Database");
if ($result = $connect -> query("Your query"))
{
}
echo "<select>";
while($row = mysqli_fetch_array($result))
{
echo "<option>" . $row['Your columns'] . "</option>"
}
echo "</select>"
?>
Example 2: get the selected value of dropdown php
function run() {
document.getElementById("resultColorValue").innerHTML = document.getElementById("Color").value;
}