Код: Выделить всё
$sql = "select * from tbl_input_values where 1";
$result = mysql_query($sql);
$resultRows = mysql_num_rows($result);
Код: Выделить всё
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=test.xls");
header("Pragma: no-cache");
header("Expires: 0");
Код: Выделить всё
if($resultRows>0){
$sep = "\t"; //tabbed character
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo mysql_field_name($result,$i) . "\t";
}
print("\n");
while($row = mysql_fetch_row($result)){
$schema_insert = "";
for($j=0; $j
Подробнее здесь: [url]https://stackoverflow.com/questions/15405470/creating-excel-from-database-and-sending-as-email-attachment[/url]