php mysql drop down menu to select data to display

php mysql drop down menu to select data to display – Create a drop-down list that options fetched from a MySQL database in PHP Example.

php mysql drop down menu to select data to display

PHP MySQL Drop Down Menu to Select Data to Display Example aslo Run this simple source code to display member name and id.

Free Live Chat for Any Issue

Step 1: Connection with Database

config.php

<?php

$link = mysqli_connect("localhost","root","","tamilrokersDB");

if(!$link)
{
    die("Connection failed: " . mysqli_connect_error());
}

?>

Step 2: Select data and display in drop down menu from database

index.php

<!DOCTYPE html>
<html>
<head>
  <title>PHP Retrieve Data from MySQL using Drop Down Menu - www.pakainfo.com</title>
</head>
<body>

<form>
  Member:
  <select>
    <option disabled selected>-- Select Member --</option>
    <?php
        include "config.php";  // Using database connection file here
        $records = mysqli_query($link, "SELECT sub_info From tblmember");  // Use select query here 

        while($row = mysqli_fetch_array($records))
        {
            echo "<option value='". $row['sub_info'] ."'>" .$row['sub_info'] ."</option>";  // displaying data in option menu
        }	
    ?>  
  </select>
</form>

<?php mysqli_close($link);  // close connection ?>

</body>
</html>

Don’t miss : How To Show Data In Dropdownlist From Database In Php?

I hope you get an idea about php mysql drop down menu to select data to display.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโ€™t forget to share.