Jump to content

[SOLVED] don't display link


daveoffy

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>' ;
    }
  }
?>

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.