php mysql数据库只获取一次数据
我正在开发一个应用程序,将用于发送短信。应用程序立即从另一个应用程序获得所需的值,并应立即自动发送消息。我希望有人能指导我如何使它自动化。如果我选择了一个id,它正在工作,但我希望自动发送而不重复php mysql数据库只获取一次数据,php,mysql,Php,Mysql,我正在开发一个应用程序,将用于发送短信。应用程序立即从另一个应用程序获得所需的值,并应立即自动发送消息。我希望有人能指导我如何使它自动化。如果我选择了一个id,它正在工作,但我希望自动发送而不重复 //I would want to have like an automatic retrieval any time it gets $sql = "SELECT name,amount, trans_id, msisdn, time_paid FROM customer"; $result1 =
//I would want to have like an automatic retrieval any time it gets
$sql = "SELECT name,amount, trans_id, msisdn, time_paid FROM customer";
$result1 = mysqli_query($conn, $sql);
$resultarr = mysqli_fetch_assoc($result1); // fetch data
$name = $resultarr['name']; // get the name from an array
$amount = $resultarr['amount']; // get the amount from the array
$transaction_id = $resultarr['trans_id']; // get the transaction id from the array
$date = $resultarr['time_paid']; // get time paid from array
$conn->close();
//the message to be sent
$message = "Dear $name we have received $amount from you. MPESA transaction Id $transaction_id on $date";
$mobilenumber = $resultarr['msisdn']; // get mobile number from array
$message_sent = $message;
$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message_sent
);
在服务器中设置一个cron作业,这将帮助您自动发送sms。是否将其放在cron上?将每分钟运行一次,但对于这个用例来说,这听起来很公平,特别是如果您在一个进程中执行多个操作,而不是像代码所暗示的那样执行一个。您应该将其构建为一个可由其他程序调用的服务,而不是db驱动的解决方案,我从另一个程序中获取详细信息,我希望它在获得这些信息后自动发送消息。好心的,我该怎么做服务呢@Jensy您没有在循环中处理查询结果您可能应该是您没有设置任何东西来表示此行已被处理您可能应该是如果您在UNIX上运行查找如果您在Windows上运行查找@RiggsFolly实际上您提出了非常理想的观点。然而,我仍然在学习这门语言,我不知道该怎么做。请引导我