My PHP Script Send incomplete mail with the data of a WHILE

0

Greetings guys I have a conflict that I explain below:

I have the following script

<?php $sql2 = "SELECT tarjetas.*, users.nombre, users.email, users.username FROM tarjetas INNER JOIN users  ON tarjetas.usuario=users.idusuario WHERE usuario = '$user' AND id_pedido = '$id_pedido' ";
$result2 = mysqli_query($db, $sql2);
//if (mysqli_query($db, $query)){
$row2count =  mysqli_num_rows($result2);
$row2 =  mysqli_fetch_assoc($result2);

  $tarjetas = '<table class="table table-bordered table-hover ">';
  $tarjetas .= '<thead><tr>';
  $tarjetas .= '<th height="17" width ="20%" align="center">';
  $tarjetas .= 'MONTO';
  $tarjetas .= '</th>';
  $tarjetas .= '<th height="17" width ="20%" align="center">';
  $tarjetas .= 'CODIGO';
  $tarjetas .= '</th>';
  $tarjetas .= '<th height="17" width ="20%" align="center">';
  $tarjetas .= 'SERIAL';
  $tarjetas .= '</th>';
  $tarjetas .= '</tr></thead>';

while ($row2 = mysqli_fetch_assoc($result2)) {
  $monto = $row2['monto'];
  $codigo = $row2['codigo'];
  $serial = $row2['serial'];
  $email_usuario = $row2['email'];
  $nombre_usuario = $row2['nombre'];

  $tarjetas .= '<tr>';

  $tarjetas .= '<td align="center">';
  $tarjetas .= $monto;
  $tarjetas .= '</td>';
  $tarjetas .= '<td align="center">';
  $tarjetas .= $codigo;
  $tarjetas .= '</td>';
  $tarjetas .= '<td align="center">';
  $tarjetas .= $serial;
  $tarjetas .= '</td>';
  $tarjetas .= '</tr>';
}
  $tarjetas .=  '</table>';

  $tarjetas_asignadas = $tarjetas;


$email = $email_usuario;
$nombre = $nombre_usuario;
$asunto = "ASUNTO";
$cuerpo = "Hola $nombre <br><br> <h1>FAVOR LEER</h1>
MENSAJE ";
$cuerpo .= '<a href= "#"><b>VER PEDIDO COMPLETO AQUI</b></a>.<br>';
$cuerpo .= "MENSAJE";
$cuerpo .= "<h2>Producto Asignado</h2>";
$cuerpo .= $tarjetas_asignadas;

enviarEmail($email, $nombre, $asunto, $cuerpo);

The error it presents is that when sending an email it is incomplete, I noticed that the first data is not sent by an example of the following data block:

monto  codigo   serial
10     111111   1111111
10     222222   2222222
10     333333   3333333

They only arrive at the mail

monto  codigo   serial
10     222222   2222222
10     333333   3333333

The first data of the table is not sent and I can not find where the error may be in my script.

    
asked by Jose M Herrera V 01.11.2018 в 19:19
source

0 answers