Jump to content

Recommended Posts

I have an add friend link and it works out all right and everything. But I need it to hide the link when I am their friend.

 

<?PHP $getid = $_GET['member_id'];
$memberid = $_SESSION['SESS_MEMBER_ID'];
  if (isset($_SESSION['SESS_MEMBER_ID'])) {
echo '<u><a href="http://gbsocial.com/friend-exec.php?friend_id='.$getid.'">Add Friend</a></u>' ;
} else{
echo '' ;} ?>

 

I need it so if $friend_id and $member_id are in the database together it does not show the link.

The database table is friend, it has member_id (my member_id) and friend_id (the persons id I added) how can I make it so it doesn't show the link if I am their friend?

Link to comment
https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/
Share on other sites

Just check the database and if the friend exists don't display the HTML that makes the link.

 

1. Get their ID

2. Check with your ID against the friends table in the database

3. If matches skip to step 5

4. Display the HTML link to add as a friend

5. Continue with the script

 

That sort of thing.

Try this...

<?php
  $getid = $_GET['member_id'];
  $memberid = $_SESSION['SESS_MEMBER_ID'];
  if (isset($_SESSION['SESS_MEMBER_ID'])) {
    $query=mysql_query("SELECT * FROM `friends` WHERE `member_id`='".$_SESSION['SESS_MEMBER_ID']."' AND `friend_id`='".$getid."'");
    if (mysql_num_rows($query)==0) {
      echo '<u><a href="http://gbsocial.com/friend-exec.php?friend_id='.$getid.'">Add Friend</a></u>' ;
    }
  }
?>

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.