Need some fast work 1-2 now
Need to work with you now to get a different lay out on my cvs file I generated - I will work with you in real time to code
Sample code -
<?php
ob_start();
require_once '../class/[login to view URL]';
require_once '../class/[login to view URL]';
$db = new Database;
if ($_SESSION['login'] == FALSE)
{
header('location:' . ADMINURL . '/[login to view URL]');
}
$or_id = $_GET['or_id'];
header('Content-Type: application/excel');
header('Content-Disposition: attachment; filename="order#'.$or_id.'.csv"');
$get_order = $db->conn->query('SELECT * FROM tbl_orders WHERE or_id = '.$or_id);
$order = $get_order->fetch_object();
$po_type = $order->or_po_type;
$purchase_order = $order->or_purchase_order;
$gross_amount = str_replace(",", "", $order->or_gross_amount);
$discount_amount = str_replace(",", "", $order->or_discount_amount);
$freight_amount = str_replace(",", "", $order->or_freight_amount);
$total_amount = str_replace(",", "", $order->or_total_amount);
$address = str_replace(","," ", stripcslashes($order->address));
$special_insruction = $order->special_instruction;
$status = $order->or_status;
$date = $order->or_date;
$row = array("$po_type, $purchase_order, $status, $date, $address, $special_insruction, $gross_amount, $discount_amount,$freight_amount, $total_amount");
$fp = fopen('php://output', 'w');
$heads = array('PO ZZZType, Purchase Order, Status, Order Date, Address, Special Insruction, Gross Amount, Discount Amount, Freight Amount, Total Amount');
$blank = array('Order ZZZDetails');
foreach($blank as $b)
{
$bl = explode(',', $b);
fputcsv($fp, $bl);
}
foreach($heads as $head)
{
$header = explode(',', $head);
fputcsv($fp, $header);
}
foreach($row as $datas)
{
$data = explode(",", $datas);
fputcsv($fp, $data);
}
$blank = array(' , ');
foreach($blank as $b)
{
$bl = explode(',', $b);
fputcsv($fp, $bl);
}
$blank = array('Order Items');
foreach($blank as $b)
{
$bl = explode(',', $b);
fputcsv($fp, $bl);
}
$table2_head = array('Part Name, Part Description, Part Information, Color, Bulk, Part Number, Bulk Unit, Quantity, Unit Price, Total Quantity, Total Price');
foreach($table2_head as $head2)
{
$header2 = explode(',', $head2);
fputcsv($fp, $header2);
}
$get_order2 = $db->conn->query('SELECT * FROM tbl_orders2 WHERE or_oid = '.$or_id);
while($order2 = $get_order2->fetch_object())
{
$part_name = $order2->or_part_name;
$part_des = $order2->or_part_d_name;
$part_info = $order2->or_part_info;
$colorselect= $order2->colorselect;
$bulk = $order2->or_bulk;
$part_no = $order2->or_part_number;
$bulk_unit = $order2->or_bulk_unit;
$quantity = $order2->or_quantity;
$unit_price = $order2->or_unit_price;
$total_quantity = $order2->or_total_quantity;
$total_price = $order2->or_total_price;
$data2 = array("$part_name, $part_des, $part_info, $colorselect,$bulk, $part_no, $bulk_unit, $quantity, $unit_price, $total_quantity, $total_price");
foreach($data2 as $datas)
{
$data_2 = explode(',', $datas);
fputcsv($fp, $data_2);
}
}
fclose($fp);
ob_flush();
?>