Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do "while fetch assoc" in CodeIgniter?

What is the equivilent make code igniter get and write all variables...

This is what I would usually do something like:

$get = mysql_query("SELECT * FROM aTable");

while($row = mysql_fetch_assoc) {
echo $row['someContent'];
}

How would I do this in codeigniter?

like image 495
PeaceDealer Avatar asked Jan 18 '13 20:01

PeaceDealer


1 Answers

After running your query, using either ->query() or the "active record" class' ->get(), use the result_array method.

$query = $this->db->query("SELECT * FROM aTable");

foreach($query->result_array() as $row){
    echo $row['someContent'];
}

Docs: https://www.codeigniter.com/user_guide/database/results.html

like image 158
Rocket Hazmat Avatar answered Oct 11 '22 08:10

Rocket Hazmat