I am developing an application that should fetch data from mysql database to send sms. I'm decided to use cron job service to run a php script to fetch the data and send the sms after every 5 minutes.
My problem is I just can not figure out a way of setting up the select statement to NOT pick a record that had been picked earlier. That only fresh since the last run are selected and data is sent. Kindly, any one lead me please...
//fetches fresh records
$sql = "SELECT name,amount, trans_id, msisdn, time_paid FROM customer ";
$result1 = mysqli_query($conn, $sql);
$resultarr = mysqli_fetch_assoc($result1); // fetch data from db
get the variables from array
$name = $resultarr['name'];
$amount = $resultarr['amount'];
$transaction_id = $resultarr['trans_id'];
$date = $resultarr['time_paid'];
// message template to be sent
$message = "Dear $name we have received $amount from you. MPESA transaction Id $transaction_id on $date.";
// requirements to send sms
$mobilenumber = $resultarr['msisdn']; // get mobile number from array
$message_sent = $message;
//passing them as service arguments
$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message_sent
);
//webservice to send sms
$client = new SoapClient("http://50.33.64.16:8080/smsengine/smsws?WSDL");
$result = $client->process($serviceArguments);
return $result;