Jump to content

not sure what you would call this...


stelthius

Recommended Posts

Hi guys,

 

Basicly i have built a login system with search members feature and when you go to testers profile you will see "Add as a friend" click it to add them, but say you searched for your own account and you clicked your profile the "Add as a friend" button wouldnt show, need a little help working this one out as im unsure what the function is actually called.

 

 

Regards Rick

Link to comment
https://forums.phpfreaks.com/topic/136043-not-sure-what-you-would-call-this/
Share on other sites

You'd check their user ID number (which could be stored in a session variable) and check it with the profile they're viewing.  If it matches don't display "Add Friend" button/link.

 

You could also go one step further and check if the friend link exists. If it does, don't display "Add Friend" but add "Remove Friend" instead.

Let's say your user id is logged in a session when you're logged in, and this is the code for your add friend list;

 

<?php
//database connection needed
$query = "SELECT id, username FROM yourusertable";
$result = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_assoc($result)){
if($row['id'] != $_SESSION['logged_id']){
echo "<a href="addfriend.php?friendid={$row['id']}">{$row['username']}</a>";
}
}
?>

 

Just substitute your code :)

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.