foreach (echo one line)

now I want to call email

foreach email
echo email


only want one echo line
$dbdetails = dbfetchsingle("SELECT BillFirstName, BillLastName, company, email, email2 FROM orders WHERE orderid = '$this->orderid'");
$this->dbdetails = $dbdetails;
$this->emails = array($dbdetails['email']);
if(strlen($dbdetails['email2']) > 0) {
     $this->emails[] = $dbdetails['email2'];
}

Open in new window

LVL 1
rgb192Asked:
Who is Participating?
 
Jerry MillerCommented:
What exactly are trying to do? The echo command displays the value (in this case email) on the screen.

This code would answer your question, but I think that you may need a different answer depending upon your intentions.

$dbdetails = dbfetchsingle("SELECT BillFirstName, BillLastName, company, email, email2 FROM orders WHERE orderid = '$this->orderid'");
$this->dbdetails = $dbdetails;
$this->emails = array($dbdetails['email']);
if(strlen($dbdetails['email2']) > 0) {
     $this->emails[] = $dbdetails['email2'];
}
echo email

Open in new window

0
 
Jerry MillerCommented:
Isn't the  orderId a unique identifier in the table? If so, the query should only return 1 row. This would eliminate the need for a 'for each' statement. Use the echo email to see the email value returned from the query.
0
 
Dushan De SilvaTechnology ArchitectCommented:
yeah use GROUP BY  email, email2
0
 
rgb192Author Commented:
so what is the echo command or the changed code
0
 
rgb192Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.