我试图插入连接到项目的用户。如果没有连接,则不应插入。但我的查询是在所有项目中插入相同的用户ID。
PS。它只有两个用户连接到一个项目。因此,插件应该为其连接的项目插入两个插件。
$getAdmin = mysql_query("SELECT *
FROM users
WHERE id = '".$_SESSION['user']['id']."'");
while($admininfo = mysql_fetch_array($getAdmin)) {
$getProsjekt = mysql_query("SELECT *
FROM cms_prosjekt
WHERE area = '".$admininfo['area']."'");
while($projectinfo = mysql_fetch_array($getProsjekt)) {
$getID = mysql_query("SELECT users.id FROM users
LEFT JOIN cms_prosjekt ON cms_prosjekt.code= users.motto
WHERE cms_prosjekt.area = '".$projectinfo['area']."' AND rank = '1'
GROUP BY users.id");
while($usersinfo = mysql_fetch_array($getID)) {
$result = mysql_query("INSERT INTO cms_messages
(type, userid, comment, posted_on,
author, status, code, area, title,
sentadmin, sentby, sentuser)
VALUES ('areas', '".$usersinfo['id']."',
'".$mytextarea."', '".$posted_on."',
'".$admininfo['real_name']."', '0',
'".$projectinfo['code']."',
'".$admininfo['area']."',
'".$title."', '1',
'".$_SESSION['user']['id']."',
'0')")
or die(mysql_error());
我左边的任何建议加入查询?