Hi,
This is script to export excel using php ;
function ExportToExcel()
{
include("connect.php");
mysql_select_db("dbit_aksbtm");
$buffer = "";
$separator = ",";
$newline = "\r\n";
// Change this to run a different query. You could also pass it in a form
//else
$sql = "select e.EmployeeID AS ' EMPLOYEE ID ', e.EmpFirstName AS ' FIRST NAME ', e.EmpLastName AS ' LAST NAME ', e.EmpLogon AS ' LOGON NAME ', e.EmpLogonSAPID AS ' LOGON SAP ID ', e.emp_EmailAddress AS ' EMAIL ADDRESS ', sp.PCsSpecName AS ' PC SPEC ', p.PCsID AS 'PC ID' from tblemployees e ,tblsections s ,tblpcs p , tblpcsspec sp where s.sectionID=e.sectionID and p.PCsID=e.PCsID and sp.PCsSpecID=e.PCsSpecID and e.Status=0 ORDER BY EmpFirstName ASC";
$result = mysql_query($sql);
// Write out column titles (field names)
$row = mysql_fetch_assoc($result);
while(list($key, $value) = each($row))
$buffer .= "\"".$key."\"".$separator;
$buffer .= $newline;
// Write out data
while ($row = mysql_fetch_assoc($result))
{
while(list($key, $value) = each($row))
$buffer .= "\"".$value."\"".$separator;
$buffer .= $newline;
}
header("Content-type: application/vnd.ms-excel");
header("Content-Length: ".strlen($buffer));
header("Content-Disposition: attachment; filename=report.csv");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
echo $buffer;
}
it is can't to take the first record . Can anyone help me?