Hi,
I am trying to get csv export in Nubuilder pro from mysql table with selected criteria. I had used in Nubuilder 2.8 which had csv export option under php code. How can this be done in Nubuilder PRO?
Regards,
AA
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
PHP Code for CSV export
Re: PHP Code for CSV export
AA,
Try running this as PHP Code..
Steven
Try running this as PHP Code..
Code: Select all
header('Content-Type: application/excel');
header('Content-Disposition: attachment; filename="Truck_Export.csv"');
$sql = "SELECT * FROM customer";
$qry = nuRunQuery($sql);
$fp = fopen('php://output', 'w');
$header = false;
while($obj = db_fetch_array($qry)){
$size = count($obj)/2;
for ($i = 0; $i < $size; $i++) {
unset($obj[$i]);
}
if($header == false) {
$a = array();
foreach ($obj as $key => $value){
$a[] = $key;
}
fputcsv($fp, $a);
$header = true;
}
fputcsv($fp, $obj);
}
fclose($fp);
-
- Posts: 18
- Joined: Tue Nov 26, 2013 9:14 am