Hello guys, I am doing a Friend system on my website, and I did the friend request, to accept, but the friends list isn't alright in some part of code because it isn't take the correct id, anyone can help me?
1. <?php
2.
3. $users = $_SESSION['username'];
4.
5. $connect = mysql_connect("localhost","root","") or die(mysql_error());
6. mysql_select_db("website");
7.
8. $user = $_GET['u'];
9.
10. $sql = mysql_query ("SELECT * FROM users");
11.
12. $result = mysql_fetch_assoc($sql);
13.
14.
15. $id3 = $result['id'];
16.
17.
18. $selusers = mysql_query("SELECT * FROM u_friends WHERE friend='$users' OR username='$users'");
19.
20. $row = mysql_num_rows($selusers);
21.
22. if($row!=0) {
23. echo "<h1>Amigos</h1>";
24. echo "<table align='center'>";
25. while($rows = mysql_fetch_assoc($selusers)) {
26. $id2 = $rows['id'];
27.
28. $read = $rows['accepted'];
29.
30.
31.
32. if($read==1)
33. if(isset($_SESSION['username'])&&$_SESSION['username']!=($rows['username'])) {
34.
35.
36. echo "<tr>";
37. echo "<td>";
38. echo "<a href='index.php?id=profile&u=".$id3."'>".$rows['username']."</a>";
39. echo "</td>";
40. echo "</tr>";
41. } else if(isset($_SESSION['username'])&&$_SESSION['username']==($rows['username'])) {
42. echo "<tr>";
43. echo "<td>";
44. echo "<a href='index.php?id=profile&u=".$id3."'>".$rows['friend']."</a>";
45. echo "</td>";
46. echo "</tr>";
47. } else {
48. echo "<table><tr><td>Não há utilizadores!</td></tr></table>";
49. }
50. echo "</table>";
51.
52. }
53.
54. }
55. else {
56. echo "<table><tr><td>Não há utilizadores!</td></tr></table>";
57. }
58.
59.
60. ?>
Anyone can help me please?When it says $id3, that's the problem
The error is when I put the echo "<a href='index.php?id=profile&u=".$id3."'>".$rows['friend']."</a>";