php - How to display my output in a dropdown list -
i want program list data mysql table in list in dropdown menu on page. here's code:
<fieldset> <legend> selecteer uw categorie </legend> <label ="categorie"> categorie </label> <select name ="categorie" id="categorie"> <datalist id ="categorie"> <option value="router">router</option> <option value="switch">switch</option> <option value="toestel">toestel</option> <option value="basisstation">basisstation</option> <option value="repeaters">repeaters</option> <option value= <?php $con=mysqli_connect("localhost","root","admin","inventarisdb"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * categorien"); while($row = mysqli_fetch_array($result)) { echo "<ul>"; echo "<li>" . $row['categorieen1'] . "</li>"; echo "</ul>"; } echo "</table>"; mysqli_close($con); ?> </option> </select> </datalist> </fieldset>
this code works perfectly, looks data need , posts in dropdown list gets posted in single line.. want listed underneath each other.. please me!
they on single line because put result in single <option>
tag.
try this:
<option value="basisstation">basisstation</option> <option value="repeaters">repeaters</option> <?php $con=mysqli_connect("localhost","root","admin","inventarisdb"); // check connection if (mysqli_connect_errno()) { echo "<option>failed connect mysql: " . mysqli_connect_error()."</option>"; } $result = mysqli_query($con,"select * categorien"); while($row = mysqli_fetch_array($result)) { echo "<option>".$row['categorieen1'] . "</option>"; } mysqli_close($con); ?> </select> </datalist> </fieldset>
edit:
sorry mistake forgot second echo
in while loop xp!
Comments
Post a Comment