8109175771

how to count data in database in php codeigniter

PHP 01-04-2021

how to count data in database in php codeigniter

Details

To count all rows from database table we can use below code in codeigniter

$this->db->from('table_name')->count_all_results();
and if you want to use where clause you can use below code
$this->db->where(['column_name'=>'condition'])->from('table_name')->count_all_results();
and also you can use below code
$query = $this->db->query('SELECT * FROM table_name');
print $query->num_rows();
if table name is 'info' and column name is 'id' then example will be as follows :


Example

Close Ads