Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

PHP foreach loop

If I write a query that has multiple  returns, how do I write the foreach loop elsewhere?

$q  = $this->db->select('*')
					->where('id', $id)
					->where('status', 'open')
$order_item = $q->result_array();

		foreach ($q as $row)
$name = $row['name'];
$address = $row['address'];
$birthdate = $row['birthdate'];

Open in new window

Lets Say this Query returns three entries.  I want to loop them in a document.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
[b]LOOP Returns Here:
John Doe 123 Test Lane January 1 2000
Jane Doe 456 Test Lane January 2 2002
Peter Doe 212 Test Lane January 3  2003[/b]
 architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,

Open in new window

My Query is much bigger than this and I need to loop different info in different parts of the document
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial