How to hang/link/attach MySql data into html Combo box.

<?php     
   error_reporting(E_ERROR | E_PARSE);   
   $conn=mysqli_connect("localhost","root","","MySqlDatabasename");
     if ($conn)
      {
       echo "database connected successfully","<br>";
      }
     else
      {
       die("Connection Aborted:" . mysqli_connect_error());
      }
?>
<html>
   <head></head>
   <body>
      <form name="form1" method="post" action="">
	 <center>
	   <fieldset style="width: 600px">
	   <legend>Create Account</legend>
	   <table>
	      <tr>
                 <td>Name</td>
		 <td>:</td>
	         <td><input type="text" name="TxtName"></td>
	         <td>
	            <select>
		       <option value=”Choose One”>Choose One</option>
		          <?php
			     $res= mysqli_query($conn, "select Email from createaccount");
			     while ($row= mysqli_fetch_array($res))
				{
			  ?>
			            <option value=”<?php echo $row["Email"];?>”> <?php echo 
                                       $row["Email"];?> </option>
			  <?php
				}
			  ?>
		     </select>
	          </td>
	        </tr>
		<tr>
		   <td>Email</td>
	           <td>:</td>
	           <td><input type="text" name="TxtEmail"></td>
	        </tr>
	      </table>
	    </fieldset>
	  </center>
	</form>
    </body>
</html>

Loading

Categories: Php Proj

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.