Hello Dev's I've been trying to work out a way to send data from a table for the past three days by mail of php. Sending data from just one column is basically easy, but it gets tricky when I want to send data from more than one column.
This is because I need to make a while
to call all the data, but how do I send this data called in the email body of the mail
function?
In the example below note that the fourth argument of the email function is just the variable that contains a set of other variables.
But when the email is submitted only the last element of the $html
variable is sent.
$buscando = mysql_query("SELECT * FROM guardapedidos WHERE id_cliente = '$idDoCliente'")
or die(mysql_error());
while ($linha = mysql_fetch_array( $buscando )) {
$nomeProdutoG = $linha['nomeProdutoG'];
$quantidadeG = $linha['quantidadeProdutoG'];
$precoProdutoG = $linha['precoProdutoG'];
$subTotalG = $linha['subTotalG'];
$totalG = $linha['totalG'];
echo $html = "
<b>Nome</b> $nomeProdutoG.<br>
<b>Quantidade</b> $quantidadeG.<br>
<b>Preço</b> $precoProdutoG.<br>
<hr>
";
}
$envio = mail($destino, $assunto, $html, $headers);