I’m pretty new to modx, I’m having to pick up where someone else left off. Can anyone tell me how change this code so it will work with Revolution 2.1
$res = $modx->db->select('*', $table_name);
$rowcount = $modx->db->getRecordCount($res);
if($rowcount > 0) {
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=brochure-request-$d.csv");
header("Pragma: no-cache");
header("Expires: 0");
while($row = $modx->db->getRow($res)) {
if($c == 0) {
$head = array_keys($row);
$out .= implode(',', $head) . "\n";
}
$vals = array_values($row);
$out .= implode(',', $vals) . "\n";
$c++;
}