I have a HTML DataList
input box, and I would like to have the options in the DataList
to be things from my SQL
database. I have been trying to make this work, but for some reason I cant. Does anyone know how this could be achieved?
Here is my code:
<?php
include_once 'connect.php';
$sql="select * FROM table";
?>
<form>
<input list="list" name="name">
<datalist id="datalist">
<?php
foreach ($dbo->query($sql) as $row) {
echo "<option value="$row[name]"/>";
}
?>
</datalist>
<input type="submit">
</form>
The option I get with this is literally $row[name]
Could someone tell me what I'm doing wrong?
Datalist id has to match the input list attribute and change the loop to "<option value=" . $row['name'] . "/>"