Display Mysql table field values in Select box

You can easily do it like this

$con = mysql_connect("localhost","root","root");
$db = mysql_select_db("Time_sheet",$con);
$get=mysql_query("SELECT Emp_id FROM Employee");

<html>
<body>
<form>
    <select> 
    <option value="0">Please Select</option>
        <?php
            while($row = mysql_fetch_assoc($get))
            {
            ?>
            <option value = "<?php echo($row['Emp_id'])?>" >
                <?php echo($row['Emp_id']) ?>
            </option>
            <?php
            }               
        ?>
    </select>
</form>
</body>
</html>

<?php
$con = mysql_connect("localhost","root","root");
 $db = mysql_select_db("Time_sheet",$con);
 $get=mysql_query("SELECT Emp_id FROM Employee ORDER BY Emp_id ASC");
$option = '';
 while($row = mysql_fetch_assoc($get))
{
  $option .= '<option value = "'.$row['Emp_id'].'">'.$row['Emp_id'].'</option>';
}
?>
<html>
<body>
<form>
 <select> 
<?php echo $option; ?>
</select>
</form>
</body>
</html>

PS : On a sidenote, please stop using mysql_* functions. Take a look at this thread for the reasons.

Tags:

Html

Mysql

Php