Jump to content

Help with PHP Inner Join


stewart715

Recommended Posts

I've posted something like this beofre but no one seems to know how to do it...

I have a table called 'Privacymode' with the columns 'uid' and 'privacyid.' The column 'uid' is the users User ID number, and the 'privacyid' is the users slected privacy mode setting, either a value of 1 (private mode) or 2 (public mode).

Now, I created a friend scripts that when a friend is added to your buddylist, their User ID number is inserted into a column 'buddy' next to a column 'uid' in the table buddylist.

When a user selects private mode, their profile is only viewable to their friends.
When a user selects public mode, their profile is viewable to everyone.
I need a script that will do the following:



When a user views someones profile, do a database query that pulls data from the table privacymode and looks to see what privacyid the profiles users uid has next to it. if it is null, show the following html <html>profile data</html>, if it is 2, show the following html <html>profile data</html>, if it is 1,

pull data from the table buddylist to see if the profiles user uid lines up with the person who is viewing the profiles uid in the column buddy..

example
user 4 = bill
user 2 = joe
joe is viewing bills profile so the script checks privacymode

uid privacyid
4      1

since bills privacyid is 1 (private)

it checks to see in buddylist

uid  buddy
4    2

since bill is joes buddy, it shows show the following <html>MY PROFILE</html>..please help please!!

if joe wasn't bills buddy i want it to show the following <html>YOU CANT SEE THIS PROFILE</html>

thanks so much you guys have been great
Link to comment
Share on other sites

I don't think a join is a good idea for this, unless you have a very good reason.  Two queries is much simpler.

The first query gets the privacy mode of the user being viewed, and if that results in 1, then the second query checks the buddy list.
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.