1

i want to send mail with data from database and using php mail() this is my code :

<?php
class emailKoala{
  public function __construct()
  {
  }
public function kirimEmailDaftar($email,$name,$order_id,$order_hargatotal){
    include "../config.php";
    $sqlbank="SELECT * FROM `bank`";
    $querybank=mysql_query($sqlbank);

    $to      = "$email";
    $subject = "order information!";
    $message = 'thanks :) this is bank account
<table>
  <tr>
    <th>Bank</th>
    <th>Number</th>
    <th>Other</th>
  </tr>'.while($arraybank=mysql_fetch_array($querybank)){
.'<tr>
<td>'.$arraybank['bank'].'</td>
<td>'.$arraybank['norek'].'</td>
<td>'.$arraybank['ket'] .'</td>
</tr>'.}.
'id order :'.$order_id.',shop again! ';

    $headers =  'MIME-Version: 1.0' . "\r\n".
                'Content-Type: text/html; charset=ISO-8859-1' . "\r\n".
                'From: shoesshe <[email protected]>' . "\r\n" .
                'Reply-To: shoesshe <[email protected]>' . "\r\n" .
                'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);

  }
}

i was try like that but

Parse error: syntax error, unexpected T_WHILE in /model/email.php on line 34

i was try before using text only and thats work, i just want to send data to that mail with table using while..

anyone can help me?

0

1 Answer 1

1

The problem is in your message string. You can't put a while in there. This will work:

$message = 'thanks :) this is bank account
<table>
  <tr>
    <th>Bank</th>
    <th>Number</th>
    <th>Other</th>
  </tr>';
while($arraybank=mysql_fetch_array($querybank)){
$message .='
<tr>
<td>'.$arraybank['bank'].'</td>
<td>'.$arraybank['norek'].'</td>
<td>'.$arraybank['ket'] .'</td>
</tr>';
}

$message .= 'id order :'.$order_id.',shop again! ';

As you can see, the while will add more text to your string in each loop. You were concatenating the while before, and it would not work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.