/
var
/
www
/
html
/
stengineers
/
admin
/
Upload FileeE
HOME
<?php // Connection error_reporting(0); $start_date = $_GET['sdate']; $end_date = $_GET['edate']; $sdate = date('Y-m-01'); $edate = date('Y-m-t'); if($start_date!="" || $end_date!="") { $pref = " created_at between '$start_date' and '$end_date'"; $prefs = " A.created_at between '$start_date' and '$end_date'"; $sdispdate = $start_date; $edispdate = $end_date; } else { $pref = " created_at between '$sdate' and '$edate'"; $prefs = " A.created_at between '$sdate' and '$edate'"; $sdispdate = $sdate; $edispdate = $edate; } $con = mysqli_connect("localhost", "stengg", "ezio@123A", "stengineers"); $filename = "leads-report-$start_date-to-$end_date.xls"; // File Name // Download file header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel"); $user_query = mysqli_query($con,"select name,email,phone,company,country,pincode,product_name,message,created_at from contact where $pref"); // Write data to file $flag = false; while ($row = mysqli_fetch_assoc($user_query)) { if (!$flag) { // display field/column names as first row echo implode("\t", array_keys($row)) . "\r\n"; $flag = true; } echo implode("\t", array_values($row)) . "\r\n"; } ?>