Hi,
I’m trying to pull data from two tables within one database and display them in a CSV file with headers ( See Attachment).
I can’t figure out how to get the firstname data which is being pulled from the second table to display in the 2nd column on my spreadsheet. It displays below the first column data and if i place null before firstname it moves it into the third column!?
Anyone know what this problem is?
<?php include('dbase.php'); //header to give the order to the browser header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=exported-data.xls'); //query get data $sql = mysql_query("SELECT date_add, shipping_number, reference, delivery_date FROM ps_orders UNION ALL SELECT firstname, null, null, null, FROM ps_customer;"); $no = 1; while($data = mysql_fetch_assoc($sql)){ echo ' '; $no++; } ?>DATE OF SALE | STOCKIST | FACTORY CODE | REFERENCE ID | DEADLINE DATE |
---|---|---|---|---|
'.$data['date_add'].' | '.$data['firstname'].' | '.$data['shipping_number'].' | '.$data['reference'].' | '.$data['delivery_date'].' |