Reputation: 905
I am working on a project and new to PHP and I need to know how to export the table data from SQLite to Excel.
I am able to do it from database but I do not know how to export to Excel using PHP.
<?php
$db = new sqlite3('I:\Preeti\explor\WebMobility.db');
$results = $db->query('SELECT * FROM VerbaliData');
while ($row = $results->fetchArray()) {
var_dump($row);
}
?>
Upvotes: 0
Views: 1607
Reputation: 117
The easiest method whould be to write your results into a CSV file which opens in Excel in a readable format.
See here for more information: http://php.net/fputcsv
$fp = fopen('file.csv', 'w');
while ($row = $results->fetchArray()) {
fputcsv($fp, $row);
}
fclose($fp);
Upvotes: 1