duan4739 2009-10-23 02:46
浏览 8
已采纳

php mail()语句

I am trying to get all the users information from the database and check the timestamp (fourteendays) and check it with the time now I got the time bit working but I can't get it to send to all the when the time is > fourteendays

 $result1 = mysql_query("SELECT * FROM accounts") or die (mysql_error()); 
 while ($row1 = mysql_fetch_array($result1)) {
 $users_email = $row1['email'];
 $user_name = $row1['user'];
 $days_time = $row1['fourteendays'];
 if($timenow > $days_time){
 mail( $users_email, $subject, $emailbody, $headers);
 echo "email sent!";
 }
 }
  • 写回答

4条回答 默认 最新

  • dousi1970 2009-10-23 02:50
    关注

    I recommend doing the date comparison in SQL, instead of pulling back all of the data in your query:

    SELECT * FROM accounts WHERE DateDiff(Now(), fourteendays) > 14
    

    Also, what is in that column in the database? If it is a timestamp, why don't you just call it as such? Am I missing something?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试