0
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: testing <test@gmail.com>' . "\r\n";
$subject = "testing";

$content = "

//html content

question How to use foreach loop inside this ?

";

$sent=mail("test@gmail.com",$subject,$content,$headers);

Edited by Dani: Formatting fixed

2
Contributors
4
Replies
21
Views
2 Years
Discussion Span
Last Post by Jiby_1
0

You use it outside and just add the variable that carries the result of the loop, for example:

$rows = '';

foreach($result as $row)
    $rows .= "
        <tr>
            <td>{$row['article']}</td>
            <td>{$row['price']}</td>
        </tr>
    ";

$content = "

    <p>Display order list:</p>

    <table>
        <thead>
            <tr>
                <th>Item</th>
                <th>Price</th>
            </tr>
        </thead>
        <tbody>
            {$rows}
        </tbody>
    </table>

";

Please: next time define the question outside the code block.

0

its for an invoice so the foreach part must create again and again.So its not possible to use the foreach outside

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.