Table users:
id firstname lastname email avatar
1 Coman Paul x@y.com ./images/a.png
Table friendships:
id user1 user2
1 1 2
2 1 5
3 3 1
4 2 3
User 1
is friend with 2,3,5
User 2
is friend with 1,3
I tried this:
$querym = mysql_query("SELECT user1
FROM friendships
WHERE user2 = '1'
UNION ALL
SELECT user2
FROM friendships
WHERE user1 = '1'");
$numrows = mysql_num_rows($querym);
if($numrows!=0)
{
Echo '<div id="members"> <ul >';
while ($row = mysql_fetch_assoc($querym))
{
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$email = $row['email'];
$avatar = $row['avatar'];
Echo '
<li>
.............
It will display all my friend but i can;t see they're names... I also tried
$querym = mysql_query("SELECT users.*, friendships.* FROM users, friendships WHERE users.id=friendships.user1 AND( friendships.user1='1' OR friendships.user2='1')");
but I got an error...
Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\OnTheRunningLine\membri.php on line 346
Please help me with a core for displaying my friends(users.id=1)
and data about them with explaining why because i need to learn it.
Oh, and if you can show me a code that will display after these results, the other users that are not friends with users.id = 1
would be great !