[eluser]John_Betong[/eluser]
Hi H8Train,
I made a mistake with the first
foreach variable so:
1. went back to the documentation
2. found the correct function,
3. tried the code snippet in one of my projects
4. copied and pasted the actual code snippet here.
5, and copied the results of the query.
Code:
//============= TEST ============================
if ($query->num_rows() > 0) {
$lf = '<br />';
echo $lf .$query->num_rows();
foreach($query->result() as $row): // amended error
echo $lf .$row->id;
echo $lf .$row->title;
echo $lf .$row->date;
// your field name
// echo $lf .$row->comments;
// my field name
echo $lf .substr($row->memo, 0, 122);
echo $lf;
endforeach;
}else{
echo 'Yes we have no records';
}//endif
die;
//============= TEST ============================
The results from the above code are:
Quote:id ==> 4
Stress management
2005-01-28 09:41:11
Stress Management Just in case you've had a rough day, here is a stress management technique recommended in all the la
id ==> 3
The hinge and the teapot
2005-01-27 11:54:11
Earl was fixing a door and he found that he needed a new hinge, so he sent his wife Mary to the hardware store. At the
id ==> 2
The elephant and the turtle
2005-01-26 12:36:43
An elephant was drinking at a watering hole when a turtle approached. The elephant looked at the turtle for a minute an
id ==> 1
The weighing machine
2005-01-25 17:25:38
While waiting at a bus stop for a bus, a woman stepped onto a weight machine that told your fortune and weight for a quart
Check the documentation for the difference between $query->result() and $query->result_array().
I prefer the former since it is less typing and less chance of making a syntax error.