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
Contents
PHP MySQL Drop Down Menu to Select Data to Display Example aslo Run this simple source code to display member name and id.
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.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.