Answer the question
In order to leave comments, you need to log in
How to make a newsletter in javascript by adding strings in the database?
Good day!
A small application has a messaging system that runs entirely in mysql. And sometimes you need to make a mailing to several users at once.
When you need to send a message to less than 500 users - php script works great. But for a larger number, duplicates often occur if you do this:
<?
$query = "SELECT `serial_num` FROM lua_account WHERE `last_login` >= '2018-06-11 00:00:00'";
$res = mysql_query( $query );
while ($item = mysql_fetch_array($res))
{
$text = "Текст сообщения";
$temp = "SELECT count(*) as count FROM lua_message WHERE `serial` = '{$item['serial_num']}' AND `Header` LIKE 'Заголовок'";
$res_temp = mysql_query($temp);
$rows = mysql_fetch_array($res_temp);
$message = $rows[0];
if ($message == 0)
{
send_message($item['serial_num'], "Автор", "Заголовок", $text);
$count += 1;
}
}
Answer the question
In order to leave comments, you need to log in
How stupid is it to do this in JS.
You just need to solve the problem in PHP correctly.
It's not clear what is your problem with duplicates? Why do they appear? How does this relate to "wait", what is the delay for?
Long-running operations, and in particular mailings, must be performed in the background. Implemented using a task queue. From the interface, add a task to the queue, and it is launched by cron in CLI mode, without restrictions on execution time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question