Jump to content

ljfreelancer88

New Members
  • Posts

    4
  • Joined

  • Last visited

ljfreelancer88's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I got a tutorial here http://www.9lessons.info/2014/03/facebook-style-friend-request-system.html this is basically what i need.
  2. ----------------------------------- | friend_id | my_id | ----------------------------------- 2 1 3 1 1 2 Users and their ID John Doe (1) Juan dela Cruz (2) Jane Doe (3) Stranger (4) Let say I'm already logged in as John Doe w/c has an ID of 1 and my friends are Juan dela Cruz and Jane Doe. I want to check the friend_id column using that function, since Stranger is not my friend, He wont be able to see posts/comments. If my codes wont be applicable, any changes or my codes are welcome. Thanks
  3. Yes, only true or false. It will check if a user he/she is on the friend table. If not, don't show the post/comment otherwise show post/comment.. Take a look at code below. The logic under else statement is too long so i have to chop it. but the concept is still the same. <?php if (!$db->viewFriendIfExistOnTbl($_SESSION['uid'])): ?> <p class="okay">You can now post on your wall, however you can't able to view all your posts without <a href="add-friend.php" title="Add Friend">adding a friend</a> on your circle. Remember, know your limit. Read <a href="house-rules.htm" title="House Rules">house rules</a>.</p> <?php else: ?> // All my posts/comments including friend's posts/comments goes here. <?php endif; ?>
  4. I am creating a simple social network, and i want the post visible only on its circle of friends but the problem is... let say user_a, user_b, user_c already registered and user_a and user_c connected/friends already and all their posts and comments are visible on their circle but when user_b write a post oh his wall, it's also visible to user_a and user_c which i dont want to happen. I dont know what was wrong on codes below. CREATE TABLE IF NOT EXISTS `user`( `uid` INT(11) AUTO_INCREMENT PRIMARY KEY NOT NULL, `uname` VARCHAR(25) NOT NULL, `pword` CHAR(60) NOT NULL, `fullname` VARCHAR(30) NOT NULL, INDEX(`uname`) ) Engine = InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci; CREATE TABLE IF NOT EXISTS `friend`( `fid` INT(11) AUTO_INCREMENT PRIMARY KEY NOT NULL, `friend_id` INT(11) NOT NULL, `my_id` INT(11) NOT NULL, `stat` ENUM('0','1') NOT NULL, INDEX(`friend_id`, `my_id`), FOREIGN KEY(`friend_id`) REFERENCES `user`(`uid`) ON UPDATE CASCADE ON DELETE CASCADE ) Engine = InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci; public function viewFriendIfExistOnTbl($uid) { $query = $this->mysqli->query("SELECT `friend_id` FROM `friend` WHERE `my_id` = '$uid' LIMIT 1"); if ($query->num_rows > 0) { return true; } }
×
×
  • 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.