我试着这样做:
$sql = "SELECT phpbb_users.user_id, phpbb_users.username, phpbb_users.user_colour, topic_poster, phpbb_topics.forum_id, phpbb_forums.forum_price
FROM phpbb_topics LEFT JOIN phpbb_forums ON phpbb_topics.forum_id = phpbb_forums.forum_id
LEFT JOIN phpbb_users ON phpbb_topics.topic_poster = phpbb_users.user_id WHERE phpbb_users.group_id = '55222'
OR phpbb_users.group_id = '55229'
OR phpbb_users.group_id = '55174'
GROUP BY phpbb_users.user_id ORDER BY phpbb_forums.forum_price DESC";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('earn', array(
'USER_ID' => $row['user_id'],
'USERNAME' => $row['username'],
'USER_COLOR' => $row['user_colour'],
'U_USER' => append_sid($phpbb_root_path . "memberlist." . $phpEx . "?mode=viewprofile&u=" . $row['user_id']),
'TOTAL_EARN' => $price,
'TOTAL_UPLOADS' => $total_price_singels+$total_price_albums,
'TOTAL_UPLOADS_LASTMONTH' => $total_upload_lastmonth,
'TOTAL_UPLOADS_MONTH' => $total_upload_month,
));
}
它不起作用.... 我需要查询每个用户,检查他写入各个论坛的消息有多少,每个论坛都有不同的价格,然后得到每个用户获得的价格
再次感谢。答案 0 :(得分:0)
如果我是正确的,那么在$total_upload_month
$sql = "SELECT phpbb_users.user_id, phpbb_users.username, phpbb_users.user_colour, topic_poster, phpbb_topics.forum_id, phpbb_forums.forum_priceFROM phpbb_topics LEFT JOIN phpbb_forums ON phpbb_topics.forum_id = phpbb_forums.forum_id LEFT JOIN phpbb_users ON phpbb_topics.topic_poster = phpbb_users.user_id WHERE phpbb_users.group_id = '55222' OR phpbb_users.group_id = '55229' OR phpbb_users.group_id = '55174' GROUP BY phpbb_users.user_id ORDER BY phpbb_forums.forum_price DESC";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)){
$template->assign_block_vars('earn', array(
'USER_ID' => $row['user_id'],
'USERNAME' => $row['username'],
'USER_COLOR' => $row['user_colour'],
'U_USER' => append_sid($phpbb_root_path . "memberlist." . $phpEx . "?mode=viewprofile&u=" . $row['user_id']),
'TOTAL_EARN' => $price,
'TOTAL_UPLOADS' => $total_price_singels+$total_price_albums,
'TOTAL_UPLOADS_LASTMONTH' => $total_upload_lastmonth,
'TOTAL_UPLOADS_MONTH' => $total_upload_month
));
}
答案 1 :(得分:0)
如果我理解正确,你需要为每个用户计算总和,尝试这样的事情:
SELECT sum(phpbb_forums.price) as total_sum,
...