Avatar of Robert Granlund
Robert Granlund
Flag 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
PHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck