Basically im trying to find all items which aren't owned by the current user and are in the same room as the user. However when i send it into an array with a while loop i always get the results doubling up is it the mysql or the while loop that's wrong? or both?!
$query = "SELECT * FROM items_to_users,items WHERE items_to_users.user_id='$user_id' AND items.room_id='$room_id' AND items_to_users.item_id != items.id";
The code to add it to the array is below:
$fetch = mysql_query($query) or die(mysql_error());
$items = array();
while ($item = mysql_fetch_array($fetch)) {
array_push($items,$item['item_id']);
}
print_r($item);
What am i doing wrong?
$query = "SELECT * FROM items_to_users,items WHERE items_to_users.user_id='$user_id' AND items.room_id='$room_id' AND items_to_users.item_id != items.id";
The code to add it to the array is below:
$fetch = mysql_query($query) or die(mysql_error());
$items = array();
while ($item = mysql_fetch_array($fetch)) {
array_push($items,$item['item_id']);
}
print_r($item);
What am i doing wrong?