///Send mail to members whom subscribed to receive mail
$one = 1;
settype($one, 'integer');
$two = 2;
settype($two, 'integer');
$query_news_mail = "SELECT M.id, M.j_email, M.j_news_alert, M.j_news_catid_notification FROM jt_members M WHERE (M.j_news_alert = $two AND M.j_news_catid_notification = $data[catid]) AND M.j_news_alert = $one;";
$mail_result = mysql_query($query_news_mail) or die(trigger_error(MYSQL_ERROR_MSG,E_USER_ERROR));
while($row_mail = mysql_fetch_assoc($mail_result)) {
//start sending mails here
echo "mail";
}
第二个子句不执行//M.j_news_alert = $ one 任何想法? 感谢
答案 0 :(得分:1)
也许你的意思
... notice the OR in place of AND ...
(M.j_news_alert = $two AND M.j_news_catid_notification = $data[catid]) OR M.j_news_alert = $one;
否则您无法满足您的WHERE条件:M.j_news_alert = $two AND M.j_news_alert = $one;
答案 1 :(得分:0)
(M.j_news_alert = $two AND M.j_news_catid_notification = $data[catid])
AND M.j_news_alert = $one;
这永远不会是true
,所以最终会得到一个空的结果集。
答案 2 :(得分:0)
SELECT M.id,M.j_email,M.j_news_alert,M.j_news_catid_notification 来自jt_members M. WHERE(M.j_news_alert = $ two AND M.j_news_catid_notification = $ data [catid])或M.j_news_alert = $ one;“
是的,我认为你需要并且意味着OR
编辑:看起来有人打败了我。