Server IP : 108.170.25.35 / Your IP : 18.222.118.117 Web Server : Apache/2 System : Linux gains.winzonesoftech.com 4.18.0-513.24.1.el8_9.x86_64 #1 SMP Mon Apr 8 11:23:13 EDT 2024 x86_64 User : softechwinzone ( 1579) PHP Version : 8.1.28 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/softechwinzone/domains/winzonesoftech.in/public_html/admin/ |
Upload File : |
<?php // Load the database configuration file include_once 'connect.php'; // Filter the excel data function filterData(&$str){ $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } // Excel file name for download $fileName = "application_" . date('Y-m-d') . ".xls"; // Column names $fields = array('S.No', 'ROLE', 'FIRST NAME', 'LAST NAME', 'DOB', 'MOBILE NO', 'EMAIL', 'GENDER', 'MESSAGE', 'SUBMITTED DATE'); // Display column names as first row $excelData = implode("\t", array_values($fields)) . "\n"; // Fetch records from database $query = mysqli_query($conn,"SELECT * FROM applier ORDER BY id DESC"); if($query->num_rows > 0){ // Output each row of the data $i=1; while($row = $query->fetch_assoc()){ // $status = ($row['status'] == 1)?'Active':'Inactive'; $lineData = array($i, $row['job'], $row['fname'], $row['lname'], $row['dob'], $row['phone'], $row['email'], $row['gender'], $row['message'], $row['createddate']); array_walk($lineData, 'filterData'); $excelData .= implode("\t", array_values($lineData)) . "\n"; $i++; } }else{ $excelData .= 'No records found...'. "\n"; } // Headers for download header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"$fileName\""); // Render excel data echo $excelData; exit;