我有以下php腳本查詢mysql數據庫以發送消息。我想發送每1000行數據庫表循環中的「消息」變量。下面是代碼,這有什麼問題?Php查詢for循環不能按預期工作
<?php
$num = $con->query("SELECT gcm_regid from gcm_users")->rowCount();
$current_num = 0;
$message = $_POST["message"];
for ($i = 0; $i < $num/999; $i++) {
$query = $con->query("SELECT gcm_regid from gcm_users LIMIT $current_num, 999");
foreach ($query as $data) {
$row[] = $data["gcm_regid"];
}
$pushStatus = send_notification($con, $row, $message);
$current_num += 999;
}
?>
https://jsfiddle.net/yLff8n5d/
錯誤消息是什麼? – Fil
那麼上面的代碼是怎麼回事? –
錯誤是循環不會執行每1000行,因爲我想 – qwertyg