Just build the data into a usable array you can then loop through. Here’s a sample. Not tested.
<?php
$hotels_array =array();
// SAMPLE Data array building for hotel //
$q = "SELECT
h.hotel_id,
h.hotel_name,
h.address,
h.city,
h.state,
h.country,
h.zipcode,
h.phone,
r.room_id,
r.room_name,
r.room_beds,
r.room_floor,
r.room_number,
r.room_description,
hf.features_id,
hf.feature_name,
f.feature_description
FROM hotels AS h
LEFT JOIN rooms AS r
ON r.hotel_id = h.hotel_id
LEFT JOIN hotels_features AS hf
ON hf.hotel_id = h.hotel_id
LEFT JOIN features AS f
ON f.features_id = hf.features_id
WHERE h.category = '$category'";
$r = mysqli_query($dbc, $q);
while($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){
$hotels_array[$row['hotel_id']]['hotel_name'] = $row['hotel_name'];
$hotels_array[$row['hotel_id']]['address'] = $row['address'];
$hotels_array[$row['hotel_id']]['city'] = $row['city'];
$hotels_array[$row['hotel_id']]['state'] = $row['state'];
$hotels_array[$row['hotel_id']]['country'] = $row['country'];
$hotels_array[$row['hotel_id']]['zipcode'] = $row['zipcode'];
$hotels_array[$row['hotel_id']]['phone'] = $row['phone'];
$hotels_array[$row['hotel_id']]['rooms'][$row['room_id']]['room_name'] = $row['room_name'];
$hotels_array[$row['hotel_id']]['rooms'][$row['room_id']]['room_beds'] = $row['room_beds'];
$hotels_array[$row['hotel_id']]['rooms'][$row['room_id']]['room_floor'] = $row['room_floor'];
$hotels_array[$row['hotel_id']]['rooms'][$row['room_id']]['room_number'] = $row['room_number'];
$hotels_array[$row['hotel_id']]['rooms'][$row['room_id']]['room_description'] = $row['room_description'];
$hotels_array[$row['hotel_id']]['hotels_features'][$row['features_id']]['feature_name'] = $row['feature_name'];
$hotels_array[$row['hotel_id']]['hotels_features'][$row['features_id']]['feature_description'] = $row['feature_description'];
}
//////////////////////////////////////////////
// All data is now in a usable array. //
// Loop through the parts you want. //
// $v = value array, just identify key //
//////////////////////////////////////////////
foreach($hotels_array as $hotel_id => $v){
$hotel_name = $v['hotel_name'];
$address = $v['address'];
$city = $v['city'];
$state = $v['state'];
$country = $v['country'];
$zipcode = $v['zipcode'];
$phone = $v['phone'];
// echo or build display of hotel info here
//Go through rooms array
foreach($v['rooms'] as $room_id => $r){
$room_name = $r['room_name'];
$room_beds = $r['room_beds'];
$room_floor = $r['room_floor'];
$room_number = $r['room_number'];
$room_description = $r['room_description'];
// echo or build display of room info here
}
//Go through hotels_features array
foreach($v['hotels_features'] as $feature_id => $f){
$feature_name = $r['feature_name'];
$feature_description = $r['feature_description'];
// echo or build display of feature info here
}
}
?>