php database excel export

Posted by user434885 on Stack Overflow See other posts from Stack Overflow or by user434885
Published on 2011-01-10T06:50:37Z Indexed on 2011/01/10 6:53 UTC
Read the original article Hit count: 166

Filed under:
|

i am using a php script to export datd from mysql into excel. the first row of the excel sheet is a column headings i want them to appear in bold how do i do this ? i am using hte following code:

$con = mysql_connect("localhost","admin","password"); if (!$con) { die('Could not connect to DB: \n' . mysql_error()); }

mysql_select_db("ALNMSI", $con);

$result = mysql_query("SELECT * FROM survey1");

$filename = "alnmsi_" . date('d-m-Y') . ".xls";

header("Content-Disposition: attachment; filename=\"$filename\"");

header("Content-Type: application/vnd.ms-excel"); $flag = false;

$flag = false;

while($row = mysql_fetch_array($result))

{ if(!$flag)

{ 
    data_keys();
    $flag = true;
} 
array_walk($row, 'cleanData');
data_array($row);

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql