-3

Can anyone please tell me , how to fetch names from mysql through php and then put all those names in hmtl select tag for user to choose one name

1

3 Answers 3

1

use a foreach

echo "<select name='username'>"; 
 while($row=mysql_fetch_array($r))
  {
  $user=array( $row['fieldname']);
  foreach($user as $val)
   {
      echo "<option value='\$val\'>".$val."</option>";
   }  
  }
 echo "</select>";  

Hope this helps

Sign up to request clarification or add additional context in comments.

Comments

0

Check here.

Hints are

    // sql connection here
    $query="SELECT * FROM emp";
    $result=mysql_query($query);
    while($r=mysql_fetch_array($result)
    {
      echo $r[0];
      // all the row that u want to fetch
    }

Comments

-1

Use PDO. It let's you access the data from SQL which you can then output in a select.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.