I didn't know how to phrase the title correctly..
I'm creating a friends list for players in my game.
I could easily create a table and have fields "players_id" and "friends_id".
so my table "friends" could be
friends players_id | friends_id ---------------------------- players_id = 1 | friends_id = 2 players_id = 1 | friends_id = 11 players_id = 1 | friends_id = 6 players_id = 1 | friends_id = 64
but with 1,000 players each having 100 friends, that's 100,000 rows.
..or i could do this:
friends players_id | friends_id ---------------------------- players_id = 1 | friends_id = (2)(11)(6)(64)
with this code:
$get_friends= explode(')(', substr($player['friends_id'], 1, -1)); foreach($get_friends as $friend_list) { $list_ids_query=$db->execute("select * from players where pID='".$friend_list[0]."'"); $friends=$list_ids_query->fetchrow(); if ($friends['id']!=$_GET['friendID']){$add_friend=1;}else{$add_friend=0;} } if ($add_friend==1){ $update=$db->execute("update friends set friends_id= CONCAT( friends_id, '(".$_GET['friendID'].")')"); }else{ //is already friend }
I'm just wondering if that saves space, works more efficiently and if I'm doing it correctly to begin with.
Thanks
EDIT: Accidentally posted thread without finishing if you didn't get the rest hitman6003