I am trying to change my code from mysql to mysqli, I am having trouble changing this bit of code though:
while($sqlrow = mysql_fetch_array($sqlresult))
{
$room = $sqlrow['Room'];
$roomHTML .= "<option value='".$room."'>" . $room . "</option>".PHP_EOL;
}
echo $roomHTML;
I do not have the variable $sqlrow in the mysqli code, below, what do I change the line $room = $sqlrow['Room'];
to below:
Full code:
$building = isset($_POST['building']) ? $_POST['building'] : '';
$sql = "SELECT Room FROM Room WHERE Building = ?";
$sqlstmt=$mysqli->prepare($sql);
$sqlstmt->bind_param("s",$building);
$sqlstmt->execute();
$sqlstmt->bind_result($dbRoom);
$roomHTML = "";
while($sqlstmt->fetch()) {
$room = $sqlrow['Room'];
$roomHTML .= "<option value='".$room."'>" . $room . "</option>".PHP_EOL;
}
echo $roomHTML;
$sqlstmt->execute();
The above code is trying to display all the rooms in a dropdown menu which matches the building they belong in.
Thanks