0

well i have info from a DB however for some reason i can't use some variables... or use other variables within the while loop!!!!

here's my code:

function SeasonPrice($roomName)
{
	require("dbCon.php");
	mysql_select_db($database);
	$res = mysql_query("select * from room where RoomName = '".$roomName."'");	
	$row = mysql_fetch_assoc($res);
	
	$Booked_month = date('F');
	
	if($Booked_month <= 'October' && $Booked_month >= 'March')
	{
		return $row['RoomInSeasonPrice'];
	}
	else
	{
		return $row['RoomOutSeasonPrice'];
	}
}

require('dbCon.php');
   
   mysql_select_db($database);
   
   $NumPeople = $_POST['numPeople'];
   
   echo "<div id='RoomBorderPayment'>";
   echo "<table border='1' width='70%' cellpadding='3'>";
   echo "<tr><th colspan='2'><p>You are booking:</p></th><th>Amount</th></tr>";
   
   $res = mysql_query("Select * from room");
   
   foreach($NumPeople as $value)
   {   
		while($row = mysql_fetch_assoc($res))
		{
			//echo $value;
			foreach($_SESSION['room'] as $Rname)
   			{
				if($Rname == $row['RoomName'])
	   			{
					$num = $value;
	   				echo "<tr><td width='55%'>1 x ".$row["RoomName"]." (".$value." Guest x ".$nights." ".$night.")</td><td width='15%'></td><td width='30%'>R".SeasonPrice($Rname)."</td></tr>";
				}
			}
		}
	   
	}
   
   echo "<tr><td></td><td><b>Total:</b></td><td>R</td></tr>";
   echo "<tr><td>A deposit of R</td><td></td><td></td></tr>";
   echo "</table>";
   echo "</div>";

the green text's value is an array and will not return the value of the whole array but rather just the first value over and over again...

where SeasonPrice() in red i had to specify in the sql statement to get the right values...

if anyone know what is going on can you pl drop me a line..

thanks

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by phpstan
0

Look at your "if" logic in the function. Numbers work better than month names. :)

This topic has been dead for over six months. 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.