Nope...don't do that...the version I posted is different...
If you were more careful with your indenting, you would notice that echo is INSIDE the while loop:
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
....
$myArr=array($id,$product,$company,$description,$web,$last,$used,$active);
$excel->writeLine($myArr);
$excel->close();
echo "data is write into hr.xls Successfully.";
}
we don't want close() (no longer needed with my updated copy of ExcelWriter) and we don't want the echo, because the send() can be the only thing displaying output. Use this:
<?php
include "../includes/db_login.php";
include("../excel/excelwriter.inc.php");
$excel=new ExcelWriter();
$myArr=array("Id","Product","Company","Description","Web Address","Last Used","Where product was last use","Is product active or inactive?");
$excel->writeLine($myArr);
$query = "SELECT * FROM $tablename";
$result = mysql_query($query);
if(!$result){
die("Could not query the database: <br/>" . mysql_error());
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$id = $row['rowid'];
$company = $row['company'];
$product = $row['product'];
$description = $row['description'];
$web = $row['web'];
$last = $row['last'];
$used = $row['used'];
$active = $row['active'];
$myArr=array($id,$product,$company,$description,$web,$last,$used,$active);
$excel->writeLine($myArr);
}
$excel->send('hr');
exit;
?>