
Originally Posted by
guido2004
Add a join to the Group table
Hmmm, it looks like 'group' is a reserved word in MySQL. You'd better rename that table to Groups or something like that, or use backticks around it in your queries.
Changed the tables so it looks like this:
Code:
SELECT
u.new_userid
, u.fname
, u.lname
, u.email
, cl.clubname
FROM fb_users u
INNER JOIN fb_club_users cu
ON cu.new_userid = u.new_userid
INNER JOIN
(SELECT
clubid
FROM fb_club_users
WHERE new_userid = $userid
) AS g
ON g.clubid = cu.clubid
INNER JOIN fb_club cl
ON cu.clubid = cl.clubid
WHERE u.new_userid <> $userid
One problem though... How do I print out the clubs with the users...
If I do this:
PHP Code:
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo $row['new_userid'].' - '.$row['fname'].'<br>';
}
Then I only get the the usernames... How do I get both the usernames and the clubs out of the same loop... with the clubs and the clubs and the cluids???
Hope you can help with this last thing... So close...
Bookmarks