Logo

Office Address

123/A, Miranda City Likaoli
Prikano, Dope

Phone Number

+0989 7876 9865 9

+(090) 8765 86543 85

Email Address

info@example.com

example.mail@hum.com

PHP CodeIgniter Count Rows in Table

The most effective method to tally question results and number of columns in table in codeigniter. On occasion you might be keen on knowing the quantity of lines in a table as opposed to bringing the actual records. Or then again to know whether your sql question really restores any records whatsoever. While you can check it utilizing select question, there are better approaches to take care of business in codeingniter.

There are two ways to count query results in codeigniter.

  •  Function: num_rows()
  •  Function: count_all_results()


1. Function: num_rows()

This function counts the number of rows returned by a sql query

$this->db->where('ID >=', 5);
$query = $this->db->get('yourtablename');
echo $query->num_rows();


2. Function: count_all_results()

The count_all_results() method is another way to determine the number of rows returned by a particular Active Record query. 

$this->db->select('*');
$this->db->from('yourtablename');
$this->db->like('filedname1', 'filedname2');
echo $this->db->count_all_results();

CodeIgniter - Count Number of Rows in Table:

If you want to count just the number of rows in a database table you can use the function $this->db->count_all().

echo $this->db->count_all('yourtablename');

Tags

  • How to display count in Codeigniter

  • Codeigniter count rows in view

  • Codeigniter count rows in controller

  • Row count Codeigniter
  • this->db->get count Codeigniter
  • Codeigniter get count table

  • Codeigniter count query results

  • Codeigniter get all data from table

Related Posts

Advantage of Offshore IT Services

Advantage of Offshore IT Services

Blazingcoders is a offshore Website Design and Web Development Company, India. We are working with many of our offshore and outsource overseas clients. who is o

Read More
P

PHP Code Check time difference is between two time slots

We are going to explain how to get the time difference between timeslots. below are the simple example given to get the time difference between the two given slots. As you can see we have used the inb

Read More
Barcode not printing and not scanning properly in zebra direct thermal printer

Barcode not printing and not scanning properly in zebra direct thermal printer

When printing barcodes to a printer of less than 600dpi, the printer may not accurately reproduce the exact bar and space ratios which can result in a read error on the barcode scanner or verifier.

Read More