View file File name : diwali-spin-export.php Content :<?php include("../include/config.php"); include("../include/functions.php"); if($_REQUEST['exportExcel']=='yes'){ $where=''; if($_REQUEST['search_from_date']!='' && $_REQUEST['search_to_date']!=''){ $where.=" and Date(p.created_at)>='".$_REQUEST['search_from_date']."' and Date(p.created_at)<='".$_REQUEST['search_to_date']."' "; } $order_by='p.order_id'; $order_by2=' desc '; $sql=$obj->Query("SELECT p.`order_id`,p.`user_id`,p.winPrizeID,p.status,p.created_at,u.fname,u.lname,u.email,i.title FROM `tbl_spinPrice` p inner join tbl_user u on u.id=p.user_id INNER join tbl_spin_inventory i on i.id=p.winPrizeID where 1=1 $where order by $order_by $order_by2",$debug=-1); $csvData=''; $csvData.="OrderID,User Info, Winning Prize, Date"; $csvData.="\n"; $reccnt=$obj->numRows($sql); if($reccnt>0){ $count=1; while($data=$obj->fetchNextObject($sql)) { $falied_log=mysqli_real_escape_string($GLOBALS['conn'],$data->falied_log); $csvData.=stripslashes($data->order_id).","; $csvData.=stripslashes($data->user_id."- ".$data->fname." ".$data->lname." (".$data->email).")".","; $csvData.=stripslashes($data->title).","; $csvData.=stripslashes($data->created_at).","; $csvData.=stripslashes($falied_log).","; $csvData.="\n"; $count++; } } header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/csv"); header("Content-Disposition: attachment; filename=diwali-spin-wheel-Report-".date("dMY_H:i").".csv"); echo $csvData; exit; header("location:".$_SERVER['HTTP_REFERER']); exit(); } ?>