Reputation: 11
PHP:
require('database.php');
$suppID = filter_input(INPUT_POST, 'suppID');
if($suppID==null || $suppID==false){
$suppID = 'Supplement-1';
}
$query = 'select * from tblsupplements where Supplement_id= :SupplementID';
$statement = $db->prepare($query);
$statement = bindValue(':SupplementID', $suppID);
$statement->execute();
$supplements = $statement->fetchAll();
$statement->closeCursor();
HTML:
<label>Supplement ID:</label>
<select name='suppID'>
<?php foreach ($supplements as $supplement): ?>
<option value="<?php echo $supplement['Supplement_id']; ?>">
<?php echo $supplement['Supplement_id']; ?>
</option>
<?php endforeach; ?>
</select>
Upvotes: 1
Views: 57
Reputation: 764
Try this, hopefully helps.
<label>Supplement ID:</label>
<select name='suppID'>
<?php foreach ($supplements as $supplement) {
echo "<option value='".$supplement['Supplement_id']."'>".$supplement['Supplement_id']."</option>";
}
?>
</select>
Upvotes: 1