Ashneel Chand Ashneel Chand - 2 months ago 16
HTML Question

post dropbox value populated from database

iam trying to populate my dropbox from my database and then retrieve it in my php code...is this possible?

<form method="POST">
<select>

while ($fethc_items = mysql_fetch_assoc($items))
{
$item_id= $fethc_items['item_id'];
$itemname = $fethc_items['item_name'];
?>
<option value="<? echo $itemname;?>">Volvo</option>
<?}?>
<input type="submit" value="Submit" />
</form>
<?
if (isset($_POST['?']))
{
}
?>

Answer

Yes you can..

Try this code. I hope its will help you.

<form method="POST">
<select name="item">
    <?php 
    while ($fethc_items = mysql_fetch_array($items))
    {
      $item_id= $fethc_items['item_id'];
      $itemname = $fethc_items['item_name'];
    ?>
      <option value="<?php echo $item_id;?>"><?php echo $itemname;?> </option>
    <?php } ?>
</select>
<input type="submit" value="Submit" />
</form>
<?php 
if (isset($_POST['item'])) {

}
?> 

Thank You!