im having trouble with my code. I'm trying to populate a drop down list from my database but the list is showing empty space instead of database entries. I would be very grateful if anyone could help me.
<?php
include("db_config.php");
$sql="SELECT * FROM brojevi";
$result=mysqli_query($connection,$sql);
echo "<select name="id" size="1">";
echo "<option value="choose">-choose-</option>";
while($row=mysqli_fetch_array($result)){
unset($id,$broj);
$id=$row['id'];
$broj=$row['brojevi'];
echo "<option value="$id">$broj</option>";
}
echo "</select>";
?>
Here is the table( its a simple one cause im just making this for practice )
CREATE TABLE `brojevi` (
`id` int(11) NOT NULL auto_increment,
`broj` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `brojevi` (`id`, `broj`) VALUES
(1, 1),
(2, 2);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…