Dirty-Rockstar Posted August 16, 2007 Share Posted August 16, 2007 im building one of those endless fun text based games Its more of a hobby to learn php. heres my situation I have a table called players which house many things including playerID i want to make another table called items, then when items are inserted i want to display items belonging to playerID. question is how do i connect the 2 of them. do i insert playerID into the item table on signup so i can use this? $id=$_SESSION['playerID']; $item1="SELECT * FROM items WHERE playerID='$id'"; $item2=mysql_query($item1) or die(mysql_error()); $item3=mysql_fetch_array($item2); print "$item3[itemnamehere]"; or is there an easier answer to query both tables. or will i have to use this method. this is my first experience in 2 tables Link to comment https://forums.phpfreaks.com/topic/65316-simple-db-query-situation/ Share on other sites More sharing options...
Dirty-Rockstar Posted August 16, 2007 Author Share Posted August 16, 2007 hrmm im thinking on doing it this way. 2 item tables 1 table to house the unique id of an item/name and information about the item and a second table housing the player ID and amount that the user has. im going to try that one = ) Link to comment https://forums.phpfreaks.com/topic/65316-simple-db-query-situation/#findComment-326204 Share on other sites More sharing options...
lemmin Posted August 16, 2007 Share Posted August 16, 2007 If you do that way, why not just have a column that holds a set of items that the player has in the player table? Link to comment https://forums.phpfreaks.com/topic/65316-simple-db-query-situation/#findComment-326206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.