stelthius Posted December 8, 2008 Share Posted December 8, 2008 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 Quote Link to comment Share on other sites More sharing options...
Adam Posted December 8, 2008 Share Posted December 8, 2008 What? Surely you don't want the ability to add yourself as a friend? What is your actual question / problem? Adam Quote Link to comment Share on other sites More sharing options...
stelthius Posted December 8, 2008 Author Share Posted December 8, 2008 thats what im saying, i dont want people to add them selves as friends, so there fore i dont weant to display the add as a friend button to them if there viewing there own profile, sorry if my original post was missleading Rick Quote Link to comment Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 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. Quote Link to comment Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 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 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.