Server IP : 162.241.126.129 / Your IP : 3.144.255.247 Web Server : Apache System : Linux 162-241-126-129.cprapid.com 4.18.0-477.27.2.el8_8.x86_64 #1 SMP Fri Sep 29 08:21:01 EDT 2023 x86_64 User : rvway5nu4 ( 1018) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/rvway5nu4/www/admin/order/ |
Upload File : |
<?php $servername = "localhost"; $username = "webinch_phpadmin"; $password = "PvF.xzxUj]37"; $dbname = "webinch_php"; $conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error()); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $file = date('dmY-His'); header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=Approve-RV-Order-$file.csv"); header("Pragma: no-cache"); header("Expires: 0"); if(!empty($_POST['category_filter'])) { $filterquery = " where order1.c_status='2' AND order2.sale_type='".$_POST['category_filter']."' "; } else { $filterquery = " where order1.c_status='2'"; } $sql = "SELECT order1.*, order2.* FROM tbl_order order1 JOIN tbl_order_items order2 ON order1.i_orderID = order2.i_orderID $filterquery "; //echo $sql; die(); $res = mysqli_query($conn,$sql); $data = array(); $data[] = array('Order No', 'Customer', 'Sub Total', 'Total','Phone', 'Staus', 'Date'); while ($row = mysqli_fetch_assoc($res)) { $sqluser = "select * from tbl_register where i_customerID='".$row['i_customerID']."'"; $resuser = mysqli_query($conn,$sqluser); $showdetail = mysqli_fetch_array($resuser); $data[] = array($row['i_orderID'], $showdetail['first_name']." ".$showdetail['last_name'], $row['subTotalPrice'], $row['totalPrice'], $showdetail['phone'], 'Approved', $row['dt_addedDate']); } $output = fopen("php://output", "w"); foreach ($data as $val) { fputcsv($output, $val); } fclose($output); ?>