I have a MySql Database and I am looking for a good easy to understand script in php that will interact with my Database and pull the information to a new Microsoft Excel file.
Please attach any good links you know of. Thanks!How do I program in php to interact with my sql database to export the data to a new excel spreadsheet?
Excel can read CSV files; these are very easy to write in PHP:
$file_handle = fopen(';filename.csv';, ';w';);
$result = mysql_query(';SELECT a,b,c FROM table';);
while( $row = mysql_fetch_assoc($result) )
{
fwrite($file_handle, $row['a'] . ';;'; . $row['b'] . ';;'; . $row['c'] . ';;\n';);
}
mysql_free_result($result);
fclose($file_handle);
No comments:
Post a Comment