Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter run mysql query and echo number of returned rows

<?=$this->db->count_all_results('users')?>

Hi, I am stuck on something. How can run a query like the below count and echo all of the returned rows? I am currently using the above statement but I need this improvement.

<?php $aa = $this->db->query("SELECT * FROM users WHERE itemNumber = 1");
like image 780
Michael Grigsby Avatar asked Dec 04 '25 17:12

Michael Grigsby


1 Answers

Use num_rows() method

<?php
 $aa = $this->db->query("SELECT * FROM users WHERE itemNumber = 1");
echo $aa->num_rows();

?>
like image 101
Ragni Munjal Avatar answered Dec 06 '25 07:12

Ragni Munjal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!