Below you can see my code. No need to show the other parts or the database table.
Code
<form method="POST" action="custInfo.php">
<center><input type="submit" id="btn" name="room"></center>
$query = mysqli_query($conn, "SELECT room_name, room_type, room_rate, inclusive, description, room_status, max_cap
FROM room
WHERE room_status = 'available'");
if(mysqli_num_rows($query)){
while($row = mysqli_fetch_assoc($query)){
echo "<div class='chooseRoom'>";
echo "<div class='indent'>";
echo "<h4>".$row['room_type']."</h4>
<h5>".$row['room_rate']."php</h5>";
echo "<img src='../images/".$row['room_type'].".jpg' width=250 height=160>";
echo "<h5>Number of Adult ";
echo "<select name='adult'>";
$x = 0;
while($x <= $row['max_cap']){
echo "<option>";
echo $x;
echo "</option>";
$x++;
}
echo "</select>";
echo " Number of Children ";
echo "<select name='children'>";
echo "<option>0</option>";
echo "<option>1</option>";
echo "<option>2</option>";
echo "<option>3</option>";
echo "<option>4</option>";
echo "<option>5</option>";
echo "</select></h5>";
echo "<table class='table'>";
echo "<thead>";
echo "<th>Inclusive</th><th>Description</th>";
echo "</thead>";
echo "<tbody>";
echo "<td>".$row['inclusive']."</td><td>".$row['description']."</td>";
echo "</tbody>";
echo "<tfoot>";
echo "<td colspan='2'>";
echo $row['room_status'];
echo "</td>";
echo "</tfoot>";
echo "</table>";
echo "</div>";
echo "</div>";
}
}
else{
echo "No rooms available in the date you desire!";
}
</form>
I need to take the value from the correct input. This code always takes the last input from the loop. And I have been trying to research about this for a day now. How do I fix this?