Jump to content

Comparing MySQL Database Tables


stewart715

Recommended Posts

I'm developing a privacy feature based on the following:
The person selects either private mode or public mode..if they select private mode, the value of 1 is inserted into a table.  if they select public mode..the value of 2 is inserted (along with their UID)..that part i already did

this is what im having trouble figuring out doing..

then i want the profile page to select that table based on that persons UID to see whether they chose 1 or 2..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 Mike has a UID of 2..buddy Joe has a UID of 4

Mike pics privacy so the table privac mode has

UID  privacyid
2        1

Joe's trying to view mikes profile so since mike picked 1 the page checks buddy list for:

UID  buddy
2        4

if it's not there..then it wont show

how...
Link to comment
Share on other sites

This query should do it

[code]
<?
$profileid = 2;  // mike
$userid = 4;  // joe

$sql = "SELECT p.*
        FROM profile p
        INNER JOIN privac 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]

returns profile data if buddy rec exists or profile is public
Link to comment
Share on other sites

I have a php template of the profile, which is where I wanted to place this code... I can't have it pull the profile data from the database..

so if the person is a friend or it is public,it shows the following html..if it is private and theyre not friends..it shows this html instead..how do i do that?
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.