php - display data in the drop down menu -


i want fetch data database in form of drop down menu. run code, name appear in drop down first 1 in database. how can make name appear in drop down?

<?php     include('config.php');      $sqladmin = "select * admin";     $result = mysql_query($sqladmin);      if($result === false) {         die(mysql_error());     }      $row = mysql_fetch_array($result);     $name1 = $row['name1']; ?> 

.

<tr>     <td>user</td>     <td>:</td>     <td>         <label>         <select name="user" id="user">             <option selected="selected"></option>             <?php echo '<option value="'.$row['name1'].'">' . $row['name1'] . '</option>';?>         </select>         </label>     </td> </tr> 

use mysql_fetch_assoc() while loop iterate result data

<?php   include('config.php');    $sqladmin = "select * admin";   $result = mysql_query($sqladmin);    if($result === false) {   die(mysql_error());   } ?>  <tr>     <td>user</td>     <td>:</td>     <td>       <label>           <select name="user" id="user">           <option selected="selected"></option>           <?php while ($row = mysql_fetch_assoc($result)) {              echo '<option value="'.$row['name1'].'">' . $row['name1'] . '</option>';           } ?>           </select>       </label>     </td> </tr> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -