We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35662
    • 12 Posts
    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 undecided

    $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++;
    	}