Click to See Complete Forum and Search --> : Export command?
sveegaard
May 3rd, 2006, 03:34 AM
Hi again, all
Is it possible to export tables from MySQL to PDF and/or XLS via PHP?
:D
sciguyryan
May 3rd, 2006, 03:50 AM
I'm not exactly shure how you can do it but this (http://www.dwalker.co.uk/phpmysqlautobackup/) may help :-)
Cheers,
Ryan Jones
sveegaard
May 3rd, 2006, 04:05 AM
Thx, but it's rather complex :D
sveegaard
May 3rd, 2006, 04:54 AM
Hmm, I've tried
<?php
$dbhost='localhost';
$dbusername='ODBC';
$dbuserpass='';
$dbname='Some_database';
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
$query = "SELECT * INTO OUTFILE 'test.pdf' FROM users";
mysql_query($query) or die(mysql_error());
?>
but Reader won't accept it (headers, perhaps?). Excel can however open it as xls.
sciguyryan
May 3rd, 2006, 05:20 AM
It maybe because the MySQL files are normally exported with a .sql extension...
Cheers,
Ryan Jones
CornedBee
May 3rd, 2006, 05:33 AM
No, this kind goes under comma separated value, CSV. That's why Excel can open it.
sveegaard
May 3rd, 2006, 05:37 AM
Any ideas, then?
Cheers
CornedBee
May 3rd, 2006, 06:17 AM
Sure.
http://www.php.net/manual/en/faq.using.php#faq.using.freepdf
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.