Forum Moderators: coopster

Message Too Old, No Replies

CSV Export

Sir iam unable to find out where csv fileis saving

         

sunil

7:47 am on Dec 27, 2007 (gmt 0)

10+ Year Member



Any one can help me please...............
Waiting for reply........

My is as follows

$fetch_order_query="SELECT o.orderid, o.status, o.total_price, g.table_name, u.fname, u.lname FROM orders o, grad_cart g, users u WHERE o.orderid = g.orderid AND o.userid = u.email and o.date='".$da."'";

header("Content-type: application/octet-stream");

header("Content-Disposition: attachment; filename=SearchOrdersToday.xls");

header("Pragma: no-cache");

header("Expires: 0");

$export = mysql_query($fetch_order_query);

$count = mysql_num_fields($export);

for ($i = 0; $i < $count; $i++) {

$header .= mysql_field_name($export, $i)."\t";

}

while($row = mysql_fetch_row($export)) {

$line = '';

foreach($row as $value) {

if ((!isset($value)) OR ($value == "")) {

$value = "\t";

} else {

$value = str_replace('"', '""', $value);

$value = '"' . $value . '"' . "\t";

}

$line .= $value;

}

$data .= trim($line)."\n";

}

$data = str_replace("\r", "", $data);

if ($data == "") {

$data = "\n(0) Records Found!\n";

}

print "$header\n$data";
exit;

eelixduppy

8:27 am on Dec 27, 2007 (gmt 0)



Hello sunil, and welcome to WebmasterWorld!

>> Sir iam unable to find out where csv fileis saving

Are you trying to save the file to your server? The way you are doing it is not actually creating a file on your server.