用户在文本框和要发送的消息上输入两个日期。我得到的值分别为$ time1和$ time2以及$ message。我在select语句中使用$ time1和$ time2,它应该在两次之间获取数据库中的移动号码。这些是接收消息的号码。
问题,我如何将这些数字保存到一个变量中,假设它们是10个数字,我应该传递给Web服务来接收消息。这些数字也需要用逗号分隔以区分它们。对于分离,我认为implode函数可以在数组中工作。 我是PHP的新手,所以有人帮助我实现这一目标。谢谢。
$message =mysqli_real_escape_string($conn, $_POST['message']);
$time1 = mysqli_real_escape_string($conn, $t1);
$time2 = mysqli_real_escape_string($conn, $t2);
$sql = "SELECT DISTINCT msisdn FROM customer WHERE DATE_FORMAT(time_paid, '%Y-%c-%e') BETWEEN ADDDATE('$time1',INTERVAL 0 HOUR) AND ADDDATE('$time2',INTERVAL '23:59' HOUR_MINUTE)";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
//Output data of each row
while($row = $result->fetch_assoc())
{
$mobilenumber = $row['msisdn'];
}
}
else
{
echo "No data in the server! ";
}
$conn->close();
sendbulk($mobilenumber, $message);
function sendbulk($mobilenumber, $message)
{
$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message
);
$client = new SoapClient("http://*****:8080/WebSms/smswebservice?wsdl");
$result = $client->process($serviceArguments);
return $result;
}
答案 0 :(得分:0)
$mob_numbers = implode(", " , $mobilenumbers);