The code below runs all fine and out puts exactly what I want - apart from one area...
Ideally I want to create an array - called summary700 (the number will change dependant on the hotel code), and in this array there are several parts.
Organiser id as a key - with an array below it - sort of like
summary700 array {
459 => array {
orm => 27
orv => 6000
arm => 27
arv => 6000
}
}
All the figures should be added like at the bottom of the for loop and the values added to an existing array if the organiser id (459 in the above example) is the same.
I think I am on the right tracks but can't seem to figure the rest out - any pointers ???
for ($i=0;$i<count($key);$i++)
{
if (@$_POST[strtolower(date("l",strtotime($tourdates[$key[$i]])))]=='on')
{
echo "<tr><td>".$info['ref']."</td>";
if ($_POST['agentSelect']=='all')
{
$getorg=do_query("SELECT company FROM agents WHERE id='".$info['organiser']."'");
list($co)=mssql_fetch_row($getorg);
echo "<td>".$co."</td>";
}
if ($_POST['hotel'][0]=='all' || count($_POST['hotel']>1))
{
$hotels=explode("<~~>",$info['hotels']);
$gethot=do_query("SELECT hotel_name FROM hotels WHERE hotel_code='".$hotels[$key[$i]]."'");
list($hot)=mssql_fetch_row($gethot);
echo "<td>".$hot."</td>";
$hotel_code=$hotels[$key[$i]];
}
else
{
$hotel_code=$_POST['hotel'][0];
}
${'summary'.$hotel_code}=array(); //start the hotel specific array
echo "<td>".$tourdates[$key[$i]]."</td>";
$beds=explode("<~~>",$info['beds']);
if ($info['nightbreak']==0)
{
$nights=explode("<~~>",$info['tdays']);
$night=$nights[$key[$i]];
}
else
{
$night=$info['tdays'];
}
if ($info['bedbreak']==0)
{
$mult=$key[$i]*5;
}
else
{
$mult=0;
}
$origrms=($beds[(0+$mult)]+$beds[(1+$mult)]+$beds[(2+$mult)]+$beds[(3+$mult)]+$beds[(4+$mult)])*$night;
echo "<td>".$origrms."</td><td>£ ".$info['total']."</td>";
if ($info['confbeds']=='')
{
$acrms=$origrms;
$acrv=$info['total'];
echo "<td>Not Confirmed</td><td>Not Confirmed</td></tr>";
}
else
{
$beds=explode("<~~>",$info['confbeds']);
$acrv=$info['conftotal']; $acrms=($beds[(0+($key[$i]*5))]+$beds[(1+($key[$i]*5))]+$beds[(2+($key[$i]*5))]+$beds[(3+($key[$i]*5))]+$beds[(4+($key[$i]*5))])*$night;
echo "<td>".$acrms."</td><td>£ ".$info['conftotal']."</td></tr>";
}
}
${'summary'.$hotel_code}[$info['organiser']]['orm']+=$origrms; //add original rooms to array
${'summary'.$hotel_code}[$info['organiser']]['orv']+=$info['total']; //add original revenue to array
${'summary'.$hotel_code}[$info['organiser']]['arm']+=$acrms; //add new rooms to array
${'summary'.$hotel_code}[$info['organiser']]['arv']+=$acrv; //add new revenue to array
}