由於你在這個線程中大部分人都知道,我有使用for循環和if語句發送大容量短信的問題。然而,我已經減少了我的查詢以下。我只使用AND的重複和每次免疫日期PHP不執行所有給定的語句
$getnumbers="SELECT
guardian_records.First_Name,
guardian_records.ID,
guardian_records.Cellphone_Number,
children_records.Child_First_Name,
children_records.Guardian_ID,
children_records.ID,
immunization_records.child_ID,
immunization_records.First_Immunization_Date,
FROM
guardian_records,
children_records,
immunization_records
WHERE
guardian_records.ID = children_records.Guardian_ID
AND children_records.ID = immunization_records.child_ID
AND immunization_records.First_Immunization_Date = CURDATE()";
$check = mysql_query($getnumbers);
$found = mysql_num_rows($check);
$details=mysql_fetch_assoc ($check);
$date1=$details['First_Immunization_Date'];
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$immunization_date1 = strtotime($date1);
if($immunization_date1 == $today)
for($counter=0;$counter<$found;$counter++)
{
$date = $date1;
$shots = "Polio and Diptheria";
$cellphonenumber=$details['Cellphone_Number'];
$childname=$details['Child_First_Name'];
$parentname=$details['First_Name'];
$msg="Dear $parentname, your child $childname is due for $shots shots on $date which is today. Message sent by Maisha Reminder System";
$encmsg=urlencode($msg);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://localhost:13013/cgi-bin/sendsms?username=Maisha&password=m123456&to=$cellphonenumber&text=$encmsg");
curl_exec ($ch);
curl_close ($ch);
}
}
我已經做到了我是在同一個頁面上面的代碼重複四次對每個可能的免疫方式查詢。但是PHP不執行整個語句。它只會停止第一個堆棧。例如,使用上面的示例代碼,它只執行這一位,並留下與上述代碼完全相同的其他代碼並進行相關更改
有沒有一種方法可以確保PHP執行所有給定的語句。如果條件滿足,FOR循環或IF語句是否阻止執行所有語句?所有幫助讚賞。
我假設一個監護人可能有多個免疫ID,並且你想確保你只發送一個包含所有可能的免疫ID的監護人的信息? – dmcnelis 2011-02-07 14:26:25