Jump to content
MakeWebGames

Recommended Posts

Posted

im building a gang mail box and only want it to show to members within that gang ive join these table together but 1 problem is that it still shows to every member in game

could someone please help thanks

$q=$db->query("SELECT m.*,u.*,g.* FROM gang_mail m LEFT JOIN users u ON m.gangid=u.gang LEFT JOIN gangs g ON g.gangID=u.gang WHERE m.gangid=g.gangID ORDER BY time DESC LIMIT $page,1");

 

<--------------EDIT------------->

i think might have fixed it i used this sql instead

$q=$db->query("SELECT m.*,u.*,g.* FROM gang_mail m LEFT JOIN users u ON u.userid='".$ir['userid']."' LEFT JOIN gangs g ON g.gangID=u.gang WHERE m.gangid=g.gangID ORDER BY time DESC LIMIT $page,10");

tell me fi you see any flaws in it thanks

Posted

keep what you had originally, but your WHERE statement block should be

WHERE m.gangid=g.gangID AND u.userid='".$ir['userid']."'

your edited SQL code will not join your tables properly.

Posted

I see a massive flaw.

 

$db->query("SELECT m.*,u.*,g.* FROM gang_mail m LEFT JOIN users u ON u.userid='".$ir['userid']."' LEFT JOIN gangs g ON g.gangID=u.gang WHERE m.gangid=g.gangID ORDER BY time DESC LIMIT $page,10");

 

Do you really need to select every column from the users table? Really every column?

Like wise do you need every column from the gang table?

I doubt it very much, try optimising your queries a bit ;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...