CSV Export (v. 2.8x)
To add a CSV exporter to the backup file:
-
Create a file called 'csv.php' and store it in the /includes/ folder of the /storeadmin/ folder.
-
In that file, add the following code:
$field_value) { if (!is_numeric($field_name)) $field_names .= " " . $field_name; } } $field_names = trim($field_names, " "); // EXPORT PRODUCTS $file_contents = ""; $exportitems = mysql_query($exportqueries, $dblink); while($exprow = mysql_fetch_array($exportitems)) { $file_content_list = ""; // LOOP FIELDS foreach (explode(" ", $field_names) AS $fld_nm) { $file_content_list .= " " . '"' . str_replace('"', '""', $exprow[$fld_nm]) . '"'; } $file_contents .= " " . trim($file_content_list, " "); } // AUTO DOWNLOAD if (empty($file_contents)) $err_msg = "No " . $filebase . " found"; else { header('Content-type: text/csv'); header('Content-Disposition: attachment; filename="' . $filebase . '.csv"'); echo $field_names . $file_contents; die(); } } } return $err_msg; } // CSV EXISTS $display_csv = (!empty($csv)) ? createcsv($csv) : ''; // SHOW ERROR $csv_error = (!empty($display_csv)) ? ""; ?>$display_csv
" : ""; // CREATE FORM OF TABLES - PLACE WHEREVER YOU WANT $csv_form = " -
Open the backup.php file in the /storeadmin/ folder.
-
Around line 14, remove the code:
require_once("includes/open.php"); -
At the very top of the page, before the opening HTML tag, add:
-
Add the following:
echo $csv_form;
right above the footer include:
include("includes/foot.php");around line 188 (in earlier versions, this will be links2.php).
Now, when you go to the 'Backup' area of the storeadmin, you'll be able to not only back up your files, but create a CSV download of each table as well. Please note: This may not work well on larger tables with several housand records.