hi
i'm pulling multiple rows of data from my database to display in a csv document but every row it displays is the same as the first row. appreciate the help.
<?php
session_start();
include 'include.php';
connect_db();
$filename = date("Ymd")."_summary.csv";
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=$filename");
$date = date("Y/m/d");
$sql = "SELECT * FROM sales WHERE datePro = '".$date."'";
$sumres = mysql_query($sql);
if ($_SESSION['summary'] = 'yes')
{
$num = mysql_num_rows($sumres);
$arr = mysql_fetch_array($sumres);
$field_arr = array('Customer Name','Quantity Bought','Amount Paid','Mode of Payment','Salespersons ID', 'Date of Sale');
foreach($field_arr as $val)
rtrim_csv_out($val);
echo "\n";
for($i=1; $i<=$num; $i++)
{
rtrim_csv_out( $arr['custName'] );
rtrim_csv_out( $arr['qty'] );
rtrim_csv_out( $arr['amntPaid'] );
rtrim_csv_out( $arr['mode'] );
rtrim_csv_out( $arr['empID'] );
rtrim_csv_out( $arr['datePro'] );
echo "\n";
}
}else{
echo "No sales Made today";
}
function rtrim_csv_out($str)
{
echo '"'.rtrim(str_replace('"','""',$str)).'",';
}
?>