I want to have sum of each value of brkgst_no got by array $mondates, where $mondates are the dates in Y-m-d format of all Mondays of current month. The code is below and not giving the correct sum of values received.
$ttl_valid_spl_monbrk_gstmls = 0;
foreach ($mondates as $mondate) {
$query = “Select brkgst_no
from pin_mls_detail
where brkgst_no != ‘’ AND pin_pin = ‘$pinid’ AND date_pin IN(”.implode(’,’,$mondates).")";
//print_r($query);
$sql = mysql_query($query);
$rows = mysql_fetch_array($sql);
while($rows = mysql_fetch_array($sql))
{
$ttl_valid_spl_monbrk_gstmls = $rows[‘brkgst_no’];
$ttl_valid_spl_monbrk_gstmls++;
}
}
echo $ttl_valid_spl_monbrk_gstmls;
It is showing wrong sum value.
I am very confused about Php Arrays.I hate working with them.Please help.