gpt4 book ai didi

php - 如何回显/打印语句

转载 作者:行者123 更新时间:2023-11-30 00:17:15 25 4
gpt4 key购买 nike

我有一个数据库,在 task_cstm 下存储事件类型(游泳、运行、足球、网球和篮球)。



另一个数据库存储销售员姓名、任务中存储的 date_start 和 date_due。



当我在 phpMyAdmin 上运行时,



SELECT COUNT( tasks_cstm.activity_type_c ) FROM tasks_cstm
LEFT JOIN tasks ON tasks.id = tasks_cstm.id_c
where tasks_cstm.activity_type_c ="swimming" and assigned_user_id="abcdefg"

我得到了我想要的结果:因为它会计算我的游泳总数。

但是,我将其放入 .PHP 文件中,该文件允许用户选择销售人员和日期,以查看销售人员在没有显示的期间推销了多少事件:

    <?php
$result0 = $GLOBALS['db']->query("SELECT tasks_cstm.activity_type_c,
COUNT( tasks_cstm.activity_type_c ) FROM tasks_cstm
LEFT JOIN tasks ON tasks.id = tasks_cstm.id_c
WHERE activity_type_c='swimming' AND date_start>='$st'
AND date_due<='$dt' AND assigned_user_id='$salesman' AND t.id=tc.id_c")

$result1 = $GLOBALS['db']->query("SELECT tasks_cstm.activity_type_c,
COUNT( tasks_cstm.activity_type_c ) FROM tasks_cstm
LEFT JOIN tasks ON tasks.id = tasks_cstm.id_c
WHERE activity_type_c='running' AND date_start>='$st'
AND date_due<='$dt' AND assigned_user_id='$salesman' AND t.id=tc.id_c")

$result2 = $GLOBALS['db']->query("SELECT tasks_cstm.activity_type_c,
COUNT( tasks_cstm.activity_type_c ) FROM tasks_cstm
LEFT JOIN tasks ON tasks.id = tasks_cstm.id_c
WHERE activity_type_c='tennis' AND date_start>='$st'
AND date_due<='$dt' AND assigned_user_id='$salesman' AND t.id=tc.id_c")

$result3 = $GLOBALS['db']->query("SELECT tasks_cstm.activity_type_c,
COUNT( tasks_cstm.activity_type_c ) FROM tasks_cstm
LEFT JOIN tasks ON tasks.id = tasks_cstm.id_c
WHERE activity_type_c='soccer' AND date_start>='$st'
AND date_due<='$dt' AND assigned_user_id='$salesman' AND t.id=tc.id_c")

$result4 = $GLOBALS['db']->query("SELECT tasks_cstm.activity_type_c,
COUNT( tasks_cstm.activity_type_c ) FROM tasks_cstm
LEFT JOIN tasks ON tasks.id = tasks_cstm.id_c
WHERE activity_type_c='basketball' AND date_start>='$st'
AND date_due<='$dt' AND assigned_user_id='$salesman' AND t.id=tc.id_c")


echo "<tr><td>" . $result0 . "</td><td>" . $result1 . "</td><td>" . $result2 . "</td><td>" . $result3 . "</td><td>" . $result4 . "</td></tr>";

有人可以帮助我并给我一些指导吗?

PS:由于我无法编辑之前的帖子,所以我将其发布在这里。

谢谢。

最佳答案

每个查询后都缺少分号。

$result2 = $GLOBALS['db']->query("SELECT tasks_cstm.activity_type_c,
COUNT( tasks_cstm.activity_type_c ) FROM tasks_cstm
LEFT JOIN tasks ON tasks.id = tasks_cstm.id_c
WHERE activity_type_c='tennis' AND date_start>='$st'
AND date_due<='$dt' AND assigned_user_id='$salesman' AND t.id=tc.id_c");

关于php - 如何回显/打印语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23555687/

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