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
https://forums.phpfreaks.com/topic/25662-help-with-php-inner-join/
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.

Archived

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

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