I have a table of which I must select information using a MySQLi Query and push it to the end of a PHP array.
The table is in this format:
table = friends
id user1 user1_id user2 user2_id datemade accepted
1 name1 1 name2 2 2015-05-27 03:24:32 1
2 name3 3 name2 2 2015-05-27 03:24:32 1
3 name3 3 name1 1 2015-05-27 03:24:32 1
4 name4 4 name2 2 2015-05-27 03:24:32 1
- id = an auto_incrementing number to keep track of everything
- user1 = the person's name that asks for friendship
- user1_id = that person's special unique id
- user2 = name of the person that accepts/decline's friendship
- user2_id = that person's special unique id
- datemade = the date it was made :P
- accepted = did he accept? (don't worry about this)
I want to select all users that are friends with $u. In this example, $u's id is 1 (name is name1). After running the query it would push it to the end of friend_array.
So if I printed this array the output would be:
2, 3
Since, id=1 is friends with id=2 and id=3
What query should I do and how would I push that to an array (I know about about array_push but I do not know how to implement it)?