Hi,
I'm using a for loop to create a sql statements for all date between a start
and end date supplied by a user. I then pull stuff out of a database and use
counter to add various things up for each date. I then want to write these
into a file but only have one line for each date.
The problem I've been having is that if there are 12 entries for a specific
date all of these go into the file but what I would like is to display the
totals for each date. The counters are adding up correctly but I'm not sure
how to get it to put one line into the file for each date. If I put the code
where it write to the file ouside the while loop it writes only the dates to
the file and not the conter values.
code:
for ($search = 0; $search <= $counter; $search++){
$sql = "SELECT * from rma WHERE (customer ='something' OR customer =
'something') AND (date_format(da te,'%e-%b-%y') = '$dateArray[$search]')";
$sqlResult = mysql_query($sq l, $conn) or die (mysql_error()) ;
while ($reportArray = mysql_fetch_arr ay($sqlResult)) {
$serial = $reportArray['serialNo'];
if (($serial > '138000000') && ($serial < '154800000')){
$batch2++;
}
$line = $dateArray[$search].",".$batch2."\ n";
fwrite($excelPo inter, $line);
}
}
fclose($excelPo inter);
I'm using a for loop to create a sql statements for all date between a start
and end date supplied by a user. I then pull stuff out of a database and use
counter to add various things up for each date. I then want to write these
into a file but only have one line for each date.
The problem I've been having is that if there are 12 entries for a specific
date all of these go into the file but what I would like is to display the
totals for each date. The counters are adding up correctly but I'm not sure
how to get it to put one line into the file for each date. If I put the code
where it write to the file ouside the while loop it writes only the dates to
the file and not the conter values.
code:
for ($search = 0; $search <= $counter; $search++){
$sql = "SELECT * from rma WHERE (customer ='something' OR customer =
'something') AND (date_format(da te,'%e-%b-%y') = '$dateArray[$search]')";
$sqlResult = mysql_query($sq l, $conn) or die (mysql_error()) ;
while ($reportArray = mysql_fetch_arr ay($sqlResult)) {
$serial = $reportArray['serialNo'];
if (($serial > '138000000') && ($serial < '154800000')){
$batch2++;
}
$line = $dateArray[$search].",".$batch2."\ n";
fwrite($excelPo inter, $line);
}
}
fclose($excelPo inter);
Comment