dropdown with database in php code example

Example: 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>"
?>

Tags:

Php Example