How do i put this into a function
<?PHP $result = $conn->query("select id, bedrijfsnaam from klanten"); echo "<html>"; echo "<body>"; echo "<select name='id'>"; while ($row = $result->fetch_assoc()) { unset($id, $name); $id = $row['id']; $name = $row['bedrijfsnaam']; echo '<option value="'.$id.'">'.$name.'</option>'; } echo "</select>"; echo "</body>"; echo "</html>"; ?>
to have it replace the bedrijfsnaam current input type here into a dropdown list from mysqli database
<?PHP <form action="" method="post"> <div> [code]<?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>ID: <?php echo $id; ?></p> <?php } ?> <strong>Bedrijfs(naam):</strong> <input type="text" name="bedrijfsnaam" value="<?php echo $bedrijfsnaam; ?>"/><br/> <strong>Factuurbedrag:</strong> <input type="text" name="factuurbedrag" value="<?php echo $factuurbedrag; ?>"/><br/> <strong>Vervaldatum:</strong> <input type="text" name="vervaldatum" value="<?php echo $vervaldatum; ?>"/><br/> <strong>Voldaan (ja/nee):</strong> <input type="text" name="voldaan" value="<?php echo $voldaan; ?>"/><br/> <strong>Opmerkingen:</strong> <input type="text" name="opmerkingen" value="<?php echo $opmerkingen; ?>"/><p/> <input type="submit" name="submit" value="Submit" /> </div> </form> ?>