Jump to content

Help with INNER JOIN


stewart715

Recommended Posts

ok i have a form where  person either selects privacy mode (which is a value of 1) or public mode (where it is a value of 2)..when submitted it is placed into a database called privacy mode with a column UID (which inputs the persons UID and a privacyid which inputs the selction they made.

I need a profile template to select that table based on that persons UID to see whether they chose 1 (which is private mode) or 2 (public mode)..if they chose 2..they can show the profile because its public mode but if they chose 1 i want the profile to check a 'buddylist' table to see if the person viewing has their user ID in the column 'buddy' next to the persons profile which their trying to viewings 'UID' (in the same row of course)

Example.. buddy PERSON A has a UID of 2..PERSON B has a UID of 4

PERSON A pics privacy so the table 'privacymode' has

UID  privacyid
2        1

PERSON B is trying to view PERSON A's profile so since PERSON A picked 1 for their privacyid the page checks buddy list for:

UID  buddy
2        4

In a nutshell:
i want it to do the query and then have it return a function if their is a relationship or if the privacyid is set to 2 (public mode)
else
return this function instead

I'm guessing I'd use INNER JOIN but how would i do this?
Link to comment
Share on other sites

well, someone on this site told me to do this:

[code]$sql = "SELECT p.*
        FROM profile p
        INNER JOIN privacymode pr ON p.UID = pr.UID
        LEFT JOIN buddylist b ON p.UID = b.UID AND b.buddy = '$userid'
        WHERE p.UID = '$profileid'
            AND ((b.UID IS NOT NULL) OR (pr.privacyid = 2) )";
[/code]

which would work I think, however, I don't want it to pull the profile data from a table like it is..i want it to simply return a certain function if it's true and return a different function if false

in very very very ignorant terms lol:

$query = the above.

if true..
return function A

else

return function B
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.