I am getting an Undefined table data error in CodeIgniter and can't figure out why. When I first try and echo the example table from the CI website, everything works fine:
function ajaxAvgSalePriceTable(){
$this->load->library('table');
$query = array(
array('Name', 'Color', 'Size'),
array('Fred', 'Blue', 'Small'),
array('Mary', 'Red', 'Large'),
array('John', 'Green', 'Medium')
);
echo $this->table->generate($query);
}
However, when I try to use my own query, I get the Undefined table data error. Here is the code that is causing the error:
function ajaxAvgSalePriceTable(){
$this->load->library('table');
$muni = $this->input->POST('muni');
$query = "SELECT SaleYear AS Y, NewSaleType AS T, count(*) AS C, tblsales.Municipality AS M, format((sum(SalePrice) / sum(Quantity1)),0) AS R FROM tblsales WHERE tblsales.SaleYear > 2007 AND tblsales.Quantity1 > 2000 AND (tblsales.NewSaleType = 'Industrial') AND tblsales.Municipality = '".$muni."' GROUP BY T,M,Y ORDER BY T,M,Y";
echo $this->table->generate($query);
}
Can anyone see what I might be doing wrong? I have tested this query separately and it works fine elsewhere, just not working here.