adding to an array variable using a loop...?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I want to create an array from results returned from a mysql query. I want it to go through each row in the returned result, and if the variable in the array staff exists add 1 to the total, if it doesnt exist, set it as one and carry on.


But when i run this and do var_dump, it just returns "1" in the array for every date.

I don't think my logic for this is correct, please help.
Cheers,
Dave.
==========
$query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start + INTERVAL 6 DAY) ";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
$x = 1;
$date = $row['Date'];
if ( isset($staff[$date] ) ){
$staff[$date] = $staff[$date] + $x ;
}
else{
$staff[$date] = $x ;
}


}

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://messenger.msn.co.uk



-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux