I have a hotel database which has multiple rates due to the room types. I'd like to list it dynamically into array (of each room type) accordingly. My data structures are:
- Hotel A : 1200-1500-1300-1700 //room type 1=1200usd/night, room type 2=1500usd/night ...
- Hotel B : 1500-1200-1300
- Hotel C : 800-850
And I'd like to list it into each room type. So I wrote:
while($rec = mysql_fetch_array($result_rate)) {
$_roomId = $rec['rid'];
$_roomRate = $rec['rate'];
list($ratez[]) = explode("-", $_rate); //because the room type is varied by hotel so I make it in array
}
So I expect the result should comes up like
echo "Room ID $_roomId=$ratez[$_roomId] USD ";
But the result is not as I expect. It keeps displaying error Fatal error: Unsupported operand types.
listdoes not work like that. Also, this code has 6 different variables all of which are used only once???