Jump to content

Archived

This topic is now archived and is closed to further replies.

stewart715

Help with INNER JOIN

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?

Share this post


Link to post
Share on other sites
I dont think you would need an inner join at all just add a privacyid column to your users table and a buddy list table and the php to handle them.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
I don't know what you mean by "return a function" for DB query.

Share this post


Link to post
Share on other sites

×

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.