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?

<?php
$q  = $this->db->select('*')
					->where('id', $id)
					->where('status', 'open')
					->get('MY-TABLE');
		
$order_item = $q->result_array();

$q->free_result();
		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.
<html>
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
<?php
[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,
</html>

Open in new window


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

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