I think I understand what you want now. Let’s just show a STATUS of the action of SENDING AN EMAIL. There are several ways to do this, I’ll tell you how I would.
Imagine a SALES LETTER:
Hello, {NOME} this is a bill of sale, Blaw, Blaw, Blaw, Blaw, ...
Blaw, Blaw, Blaw, Blaw.
And you have to send it to an email list. Now imagine that you have a table with that email list.
TBL_EMAIL
ID | NOME | EMAIL | STATUS
1 | Fulano | [email protected] | 0
2 | Beutrano | [email protected] | 0
3 | Cicrano | [email protected] | 0
Explanation of status
- 0 = AWAITING DISPATCH
- 1 = SENT
Now you need to start the action and pick up an email to start sending the email. With a SELECT will need to return only one email address to be sent.
SELECT * FROM `TBL_EMAIL` WHERE `STATUS`=0 LIMIT 1
So it will only bring one email at a time.
FRONTEND
Now let’s go to the frontend. At this point you will need a page for the action to be shown and executed. For example www.site.com.br/sending.php and on this page you will have a loop script to follow the actions.
www.site.com.br/sending.php
<p id="status"></p>
<script>
function realtime() {
$.get("ajax-email.php", {}, function(data) {
$("#status").html(data.email +' - ' data.status + '<br>');
}).done(function () {
// se não dizer que espere, apenas coloque 0 ou deixe apenas a função realtime()
setTimeout(function() {
realtime();
}, 100);
});
}
// função sendo chamada pela primera vez
realtime();
</script>
ON THE PAGE ajax-email.php
When the email sending action is triggered.
// Primeiro vc faz um select no email com o SQL que mencionei acima
// SELECT * FROM `TBL_EMAIL` WHERE `STATUS`=0 LIMIT 1
// Vo meio vc terá suas funções me metodos para enviar um email
$return = acao_enviar($nome, $email, $mensagem);
// verificando se deu certo o envio de email
if($return) {
$status = 'Sucesso';
// neste ponto vc muda o statos no banco de dados
// UPDATE TBL_EMAIL SET STATUS=1 WHERE ID=$id
} else {
$erro = 1;
$status = 'Erro';
}
// Por fim o retorno final da ação
die(json_encode(array(
'erro' => $errro,
'email' => $email,
'status' => $status
)));
The page should look like this:
[email protected] - Sucesso
[email protected] - Erro
[email protected] - Sucesso
This is pretty basic, but it’s just for you to have an idea of how to do it and what I’ve understood
I can’t understand what you want.
– David Costa
I edited ,now I could see if you could understand me ?
– Alencar Luiz
Hello Alencar, and welcome to [en.so], for someone to help you, I believe you need to put part of the sources where this data is assembled
– Caputo