所以我有两个问题,第一个问题根据 $_SESSION 选择一个数组,然后在第二个选择中使用。
我的问题是,例如,当我使用一个条目时,每件事都可以,表格将如下所示:
|DATA| USER1|
|DATA| USER2|
|DATA| USER3|
但是,如果我必须为同一个用户输入条目,我会得到这样的重复:
|DATA| USER1| [1]
|DATA| USER1| [2]
|DATA| USER2|
|DATA| USER3|
|DATA| USER1| DUPLICATE of FIRST ENTRY USER ABOVE [1]
|DATA| USER1| DUPLICATE OF SECOND ENTRY USER ABOVE [2]
我的代码如下所示:
function make_table($user_id){
first_query with this select `Select U.user_id
from users U, tasks T
where T.assigned_to = U.user_id
and T.status='Assigned'
and U.parent_id = $_SESSION[userid]`;
foreach ($query_result_worker as $row){
$user_id_worker = $row['user_id'];
//second_query with this select
SELECT T.task_id, T.job_server_id, T.TIMESTAMP, TT.task_type_name, T.STATUS,
UO.username AS customer_name, UO.user_id AS customer_id, T.STATUS, T.quantity,
T.order_id, U.username, T.priority, T.assigned_time, U.username, O.order_id
FROM task_type TT, orders O, users UO, task_assignment T
LEFT JOIN users U
ON T.assigned_to = U.user_id
WHERE T.task_type_id = TT.task_type_id
AND O.order_id = T.order_id
AND O.user_id = UO.user_id
AND T.STATUS = 'Assigned'
AND T.assigned_to = $ROW [user_id]
AND T.TIMESTAMP <= CURRENT_TIMESTAMP
ORDER BY T.priority DESC, DATE (T.TIMESTAMP), T.quantity DESC, T.task_id
foreach ($result as $tablerow) {
make the printing table stuff
}
}
所以我不知道为什么当我有两个条目时它会重复,请帮忙?
PS:如果我为同一用户输入 3 个条目,则同一用户将输入 6 个条目,也会重复。