stewart715 Posted October 19, 2006 Share Posted October 19, 2006 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 didthis 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 4Mike pics privacy so the table privac mode hasUID privacyid2 1Joe's trying to view mikes profile so since mike picked 1 the page checks buddy list for:UID buddy2 4if it's not there..then it wont showhow... Quote Link to comment Share on other sites More sharing options...
Barand Posted October 19, 2006 Share Posted October 19, 2006 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 Quote Link to comment Share on other sites More sharing options...
stewart715 Posted October 20, 2006 Author Share Posted October 20, 2006 Thank you so much! Quote Link to comment Share on other sites More sharing options...
stewart715 Posted October 21, 2006 Author Share Posted October 21, 2006 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? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 21, 2006 Share Posted October 21, 2006 [code]<?php$res = mysql_query($sql) or die (mysql_error());if (mysql_num_rows($res) == 0 { // cannot view profile}else { // show profile}?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.