Okay the problem is adding another result to the multi-dimensional array
When i perform var_dump on the returned varialbe $tips i get
array(1) { [2]=> array(1) { [0]=> string(10) "2003-03-07" } }
I know that there are 2 results missing here for when the key of the array is 1 ($staffid = 1)
the results are such that the array should look like this
array(1) {[1]=> array(2) {[0]=>string(10) "2003-03-06" [1]=> string(10) "2003-03-07" }
[2]=> array(1) { [0]=> string(10) "2003-03-07" }}
now I just need some help getting my code to produce the second output.
=================================================================
<?
function tips($weekstart){
$start = date('Ymd',strtotime($weekstart));
$query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start + INTERVAL 6 DAY) ORDER BY staffid";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
$staffid = $row[StaffId];
if(!isset($tips[$staffid])){
$tips = array( $staffid => array($row[Date]) );
}
else{
if ($tips[$staffid]){
for($x=0; $x<=7; $x++){
if (!empty($tips[$staffid][$x])){
/* do nothing */
}
else{
$tips[$staffid] = array( $x => $row[Date]);
}
}
}
}
}
return $tips;
}