return number of rows - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: return number of rows (/showthread.php?tid=54636) |
return number of rows - El Forum - 09-18-2012 [eluser]rochellecanale[/eluser] hey guys i just want to ask what can i do to return the number of rows in my mysql tables? ive got an error when i used $query->num_rows(); not actually an error but it returned to '1'? here's my code hope you can help me. my view Code: <tr> my model function Code: public function countTotalSalesRecord(){ my controller Code: public function viewMemberSales(){ =========================================================================================== it results to Total Records: 1 return number of rows - El Forum - 09-18-2012 [eluser]rochellecanale[/eluser] ok i found out the answer i must use the function count_all_results() and thats all. return number of rows - El Forum - 09-18-2012 [eluser]john_j[/eluser] what it returns is correct, it has to return '1' because there is only one row. Do something like this to get the count: Code: $result = $this->db->query('select count(*) as total_count from some_table'); |