View file File name : mithaas-export-users.php Content :<?php include("../include/config.php"); include("../include/functions.php"); $objmithaas = new DB($db_namemithaas, $hostmithaas, $usernamemithaas, $passwordmithaas); if($_REQUEST['exportExcel']=='yes'){ $where=''; if($_REQUEST['search_uname']!=''){ $name=$_REQUEST['search_uname']; $where.=" and fname like '".$name."%'"; } if($_REQUEST['search_email']!=''){ $name=$_REQUEST['search_email']; $where.=" and email='".$name."'"; } if($_REQUEST['search_mobile']!=''){ $name=$_REQUEST['search_mobile']; $where.=" and mobile ='".$name."' "; } if($_REQUEST['search_from_date']!='' && $_REQUEST['search_to_date']!=''){ $where.=" and register_date>='".$_REQUEST['search_from_date']."' and register_date<='".$_REQUEST['search_to_date']."' "; } $order_by=' id '; $order_by2='desc'; $sql=$objmithaas->Query("select * from $tbl_user where 1=1 $where order by $order_by $order_by2 ",$debug=-1); $csvData=''; $csvData.="Register Date,Name, Email ,Mobile,Phone,Addr5ess,Area,City, Pincode,Status"; $csvData.="\n\r"; $reccnt=$objmithaas->numRows($sql); if($reccnt>0){ $count=1; while($data=$objmithaas->fetchNextObject($sql)) { $csvData.=date('d M Y H:i',strtotime($data->register_date)).","; $csvData.=stripslashes($data->fname)." ".stripslashes($data->lname).","; $csvData.=stripslashes($data->email).","; $csvData.=$data->mobile.","; $csvData.=stripslashes($data->phone).","; $csvData.=str_replace(",",";",stripslashes($data->house_no))." ".str_replace(",",";",stripslashes($data->street))." ".str_replace(",",";",stripslashes($data->complex))." ".str_replace(",",";",stripslashes($data->landmark)).","; $csvData.=str_replace(",",";",stripslashes($data->area)).","; $csvData.=getField('city',$tbl_city,$data->city_id).","; $csvData.=stripslashes($data->pincode).","; if($data->status==1){ $status='Activated';}if($data->status==0){ $status='Dectivated';} $csvData.=stripslashes($status).","; $csvData.="\n\r"; $count++; } } header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/csv"); header("Content-Disposition: attachment; filename=Mithaas-Users-Report-".date("dMY_H:i").".csv"); echo $csvData; exit; header("location:".$_SERVER['HTTP_REFERER']); exit(); } ?>