gpt4 book ai didi

php - MYSQL 查询忽略 php 中的结果

转载 作者:行者123 更新时间:2023-11-29 23:25:41 25 4
gpt4 key购买 nike

编辑这个问题,因为它已经缩小了范围。如果我按照下面手动运行 SQL 查询,即使我知道 nfw_lead_messages_sent.reply = '2' 至少有 5 个应该显示的结果,它也不会显示任何结果。

SELECT
CONCAT(title,' ',first_name,' ',last_name) AS lead_name,
nfw_leads.mobile,
nfw_leads.lead_date,
nfw_leads.service_type,
nfw_leads.state,
nfw_lead_messages_sent.reply
FROM
nfw_users
LEFT JOIN nfw_leads ON nfw_leads.allocate_to = nfw_users.id_num
LEFT JOIN nfw_lead_messages_sent ON nfw_lead_messages_sent.sent_to_id = nfw_leads.allocate_to
WHERE
nfw_users.id_num = '3513'
GROUP BY
nfw_leads.first_name,
nfw_leads.last_name,
nfw_leads.mobile,
nfw_leads.service_type

HAVING nfw_lead_messages_sent.reply = '2'
Order by
lead_date ASC

如果我手动运行 SQL 查询 nfw_lead_messages_sent.reply = '1' 则会显示结果。请参阅下面的内容,了解适用于 = '1' 但当我将其更改为 = '2' 时不起作用

SELECT
CONCAT(title,' ',first_name,' ',last_name) AS lead_name,
nfw_leads.mobile,
nfw_leads.lead_date,
nfw_leads.service_type,
nfw_leads.state,
nfw_lead_messages_sent.reply
FROM
nfw_users
LEFT JOIN nfw_leads ON nfw_leads.allocate_to = nfw_users.id_num
LEFT JOIN nfw_lead_messages_sent ON nfw_lead_messages_sent.sent_to_id = nfw_leads.allocate_to
WHERE
nfw_users.id_num = '3513'
GROUP BY
nfw_leads.first_name,
nfw_leads.last_name,
nfw_leads.mobile,
nfw_leads.service_type

HAVING nfw_lead_messages_sent.reply = '1'
Order by
lead_date ASC

最佳答案

首先将 $data 转换为整数

   $data = intval($_GET["data"])); 

然后按如下方式使用

   if($data === 1) {
} elseif($data === 2) {
} elseif(empty($data)) {
}

关于php - MYSQL 查询忽略 php 中的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26991204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com