I am facing a problem on downloading the SQL table value. I initially tried in Local network it works fine but when i shifted to cloud hosting of php pages it give me error as follows:
Warning: Cannot modify header information - headers already sent by (output
started at /storage/ssd4/739/9447739/public_html/admindashboardentry.php:85)
in /storage/ssd4/739/9447739/public_html/admindashboardentry.php on line 738
Warning: Cannot modify header information - headers already sent by (output
started at /storage/ssd4/739/9447739/public_html/admindashboardentry.php:85)
in /storage/ssd4/739/9447739/public_html/admindashboardentry.php on line 739
but it displays the sql table on webpage below these warning.
while when i was working on Local network it works fine.
below some code i am using to download the sql table entries.
//EXCEL DOWNLOAD SET START
//if condition to check download button is pressed and start download the csv file
if(downloadExcel() === 1){
$empid = $_POST['empid'];
$projectcode = $_POST['projectcode'];
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
// Connection
include('connection.php');
$date = date('Y-m-d h:i:s A');
$empName = getEmpNameById($empid);
$filename = $empName." - ".$date.".xls"; // File Name
// Download file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
//table name in database is in lowercase as 'cip004'
$empidTable = strtolower($empid);
$user_query = "SELECT * FROM $empidTable WHERE EmpID = '$empid' AND ProjectCode = '$projectcode' AND Date BETWEEN '$startdate' AND '$enddate'";
$result = $conn->query($user_query);
tableHeading();
//loop the query data to the table in same order as the headers
while ($row = $result->fetch_assoc()){
$status = statusOfEntry($row['Status']);
tableRow($row, $status);
}
echo '</table>';
}