daveoffy Posted December 7, 2008 Share Posted December 7, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/ Share on other sites More sharing options...
DeanWhitehouse Posted December 7, 2008 Share Posted December 7, 2008 In the query use $sql = "SELECT * FROM table WHERE member_id = 'member_id_number' AND friend_id = 'friend_id_number'"; Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708822 Share on other sites More sharing options...
daveoffy Posted December 7, 2008 Author Share Posted December 7, 2008 How is that suppose to get rid of the link if I am already their friend? Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708825 Share on other sites More sharing options...
DeanWhitehouse Posted December 7, 2008 Share Posted December 7, 2008 I was hoping you could at least work out some of it. What you do is then use mysql_num_rows(); to find out if you are there friend, then use an IF statement. Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708830 Share on other sites More sharing options...
daveoffy Posted December 8, 2008 Author Share Posted December 8, 2008 I have been trying this over and over again but I just can't seem to get it right, I even asked some people online and googled it but no luck. Please tell me what to put in the num_rows () or tell me a website that I could use that could help me. Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708909 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708922 Share on other sites More sharing options...
daveoffy Posted December 8, 2008 Author Share Posted December 8, 2008 I know what to do, just don't know the code to do it with. Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708941 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 What is the structure of your friends table? Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708945 Share on other sites More sharing options...
daveoffy Posted December 8, 2008 Author Share Posted December 8, 2008 member_id and friend_id Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708968 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 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>' ; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708972 Share on other sites More sharing options...
daveoffy Posted December 8, 2008 Author Share Posted December 8, 2008 Thank you. I was really close with my code, I just added some useless stuff that was messing up the code. Quote Link to comment https://forums.phpfreaks.com/topic/135976-solved-dont-display-link/#findComment-708977 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.