I’m trying to make a dropdownlist based on data I get from the database but I can’t display them. Could someone lend me a hand?
include '../opdrachten/connectionPDO.php';
function Select()
{
$query =$db->prepare("SELECT naam FROM opdracht4");
$query->execute();
foreach ($query as $row)
{
echo '<option value="'.$row['naam'].'">"'.$row['naam'].'"</option>';
}
}
<select name="projectleider">
<?php Select(); ?>
</select>
Pass the
$dbinto the function to get it in scope.