06-23-2008, 03:45 PM
|
#2 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Why not do it to CSV, tested and this works for Open Office so it should work for excel (but microsoft being evil, it probably wont), there are also some bits of incorrect code within your example which i have fixed in mine:
PHP Code:
$conn = mysql_connect($local,$user,$pass) or die ("Unable to connect to database.");
mysql_select_db($db, $conn);
$result = mysql_query("SELECT * FROM users") or die('Error, query failed'); $csv = ''; $fileName = 'test.csv'; while($row = mysql_fetch_array($result)) { $csv .= implode($row, ',')."\n"; }
header("Content-Type: text/comma-separated-values"); header("Content-Disposition: attachment; filename=$filename"); echo $csv;
Hopefully that will give you what you need to get going.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
Last edited by sketchMedia : 06-24-2008 at 09:22 AM.
Reason: removed 'var_dump' left it in by accident when testing
|
|
|
|