Update rows in a while loop php

喜你入骨 提交于 2019-12-12 05:27:45

问题


I have a working mail script and there are times that the sending times out because our internet connection is not stable. I was advised to mark sent messages to the mails after it has been sent. I've tried this script but so far it only updates the first email it sends to and not the rest.

if(isset($row_get_sender['setfrom_email'])) {
    do {
        $mail->AddAddress($row_get_recipient['email']); 
        $mail->Send();
        $update_recipient;
        $mail->ClearAddresses();
    } while($row_get_recipient = mysql_fetch_assoc($get_recipient));
}

and my queries:

mysql_select_db($database_mail, $mail);
$query_get_recipient = "SELECT * FROM `to` WHERE `mailSent` = '0'";
$get_recipient = mysql_query($query_get_recipient, $mail) or die(mysql_error());
$row_get_recipient = mysql_fetch_assoc($get_recipient);
$totalRows_get_recipient = mysql_num_rows($get_recipient);

$query_update_recipient = "UPDATE `to` SET `mailSent` = '1' WHERE `email` = '$row_get_recipient[email]'";
$update_recipient=mysql_query($query_update_recipient,$mail) or die (mysql_error());

来源:https://stackoverflow.com/questions/13619682/update-rows-in-a-while-loop-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!