1
I wanted to put some data from the database in a combobox but I’m not getting it, I think the problem will be the connection to the database but I don’t know what will be wrong, can help me?
<?php
...
$dbconn = mysqli_connect($servername, $username, $password, $dbname)or die("Failed to connect to database:" . mysqli_error($dbconn));
$query = "SELECT nome FROM Medicos";
$data = mysqli_query($dbconn, $query);
$result = mysqli_num_rows($data);
?>
<form name="medicos" method="post" action="">
<label for="">Selecione um médico</label>
<select>
<option>Selecione...</option>
<?php while($prod = $result->fetch_assoc()) {
echo '<option value="'.$prod['nome'].'">'.$prod['nome'].'</option>';
}
?>
</select>
What’s the problem? Does it give an error? If so, edit the question and add the message. If not, is the result different than expected? If yes, describe what was the result obtained and what was expected.
– Woss