Click here to Skip to main content
16,015,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
PHP
$output = '';
if(isset($_POST["query"]))
{
 $search = mysqli_real_escape_string($connect, $_POST["query"]);
 $query = "
  SELECT * FROM deserved 
  WHERE DeName LIKE '".$search."'
 
 ";
}
else
{
 $query = "
  SELECT * FROM deserved  
 ";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
 $output .= '
 
   
 ';
 while($row = mysqli_fetch_array($result))
  
 {
	  
  $output .= '
    <input type="text"  " value="'.$row["DeFamilyNum"].'">
    
      
  ';

 }


What I have tried:

select option from database
i need to change input to combo box
Posted
Updated 6-May-17 3:00am
v2
Comments
ZurdoDev 20-Apr-17 14:22pm    
I imagine there are lots of examples online for php and databinding a dropdown.

1 solution

Well you can use the following way as I have shown in the below code
PHP
<?php
echo "<select>";
while($row = mysqli_fetch_array($result)){
 echo "<option>";
 echo $row['DeFamilyNum'];
 echo "</option>";
}
echo "</select>";

Hope this will help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900