0

hey i have multiple sessions with aray values from DB within, now i'd like to run through a loop and have all those values which displayed...

here's my code:

echo "<div id='RoomBorderPayment'>";
   echo "<table border='0' width='70%' cellpadding='3' style='border-width:thin'>";
   echo "<tr><th colspan='2'><p>You are booking:</p></th><th>Amount</th></tr>";
   
   $res = mysql_query("Select * from room");
   
   		$_SESSION['booked_rooms'] = array(); //makes an $_SESSION array
		$_SESSION['booked_room_price'] = array(); 
   		$index = 0;
		$total = 0;
		while($row = mysql_fetch_assoc($res))
		{
			foreach($_SESSION['room'] as $Rname)
   			{
				if($Rname == $row['RoomName'])
	   			{
					$_SESSION['booked_rooms'][] = $row['RoomName']; //populates S_SESSION array
	   				echo "<tr><td width='55%'>1 x ".$row["RoomName"]." (".$NumPeople[$index]." Guest x ".$nights." ".$night.")</td><td width='15%'></td><td width='30%' align='center'>R".SeasonPrice($Rname, $nights)."</td></tr>";
					$index++;
					$total += SeasonPrice($Rname, $nights);
					$_SESSION['booked_room_price'][] = SeasonPrice($Rname, $nights);//collects all the room prices
					echo '<br/>';
				}
			}
			
		}
	   
	
   
   echo "<tr><td></td><td align='right'><b>Total:</b></td><td align='center'><b>R".$total."</b></td></tr>";
   echo "<tr><td>A deposit of <b>R".(number_format($total, 2, '.', '')/2)."</b> will secure this booking</td><td></td><td></td></tr>";//".deposit()."
   echo "</table>";
   echo "</div>";

----------------------
next page
---------

var_dump($_SESSION['booked_room_price']);
var_dump($_SESSION['booked_rooms']);

echo "<br>";

foreach($_SESSION['booked_rooms'] as $key => $booked)
{
	echo $booked." ".$_SESSION['booked_room_price']."<br>";
}

so with the var_dump() it shows that all values are being passed correctly however it won't display the $_SESSION values instead just displays the word 'Array'...

if anyone can help me on this pl my brain is fried

Thanks

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by gchurch
0

You can't echo an array, it isn't that smart. If you want to dump it, you can use print_r. If you want to do your own formatted display then you need to spin through the array pulling out the values and displaying them or referencing them individually (e.g. $_SESSION[0] )

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.