php mysql数据库只提取一次数据

时间:2016-06-10 08:22:22

标签: php mysql

我正在开发一个用于发送短信的应用程序。应用程序立即从另一个应用程序获取所需的值,并且应该立即发送消息AUTOMATICALLY。我希望有人能指导我如何让它自动化。如果我选择一个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 = 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
       );

1 个答案:

答案 0 :(得分:1)

在服务器中设置一个cron作业,这将帮助您自动发送短信。