katarra Posted September 11, 2010 Share Posted September 11, 2010 I'm trying to combine 3 tables (attacks, spells, skills) where it brings in all the information from attacks and spells into the table skills. The common row between all 3 is "name". Here is what I have so far. $query = "SELECT * FROM `skills`,`attacks`,`spells` WHERE (`attacks.name`=`skills.name` OR `spells.name`=`skills.name`) AND `user_id`='".$_SESSION['userid']."'"; Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213168-problem-combining-tables/ Share on other sites More sharing options...
Gheeda Posted September 11, 2010 Share Posted September 11, 2010 What are you trying to accomplish with this code? And by that I mean, after you query this information...how are you using/displaying it? And secondly, why are you querying all at once....what benefit does this have for you? Quote Link to comment https://forums.phpfreaks.com/topic/213168-problem-combining-tables/#findComment-1109996 Share on other sites More sharing options...
katarra Posted September 11, 2010 Author Share Posted September 11, 2010 I'm having it list available "abilities" that someone can use in a battle script. I don't know of a different way to do it, so that's why I put it like this. I'm still a novice at php. Quote Link to comment https://forums.phpfreaks.com/topic/213168-problem-combining-tables/#findComment-1109998 Share on other sites More sharing options...
Gheeda Posted September 11, 2010 Share Posted September 11, 2010 I'm having it list available "abilities" that someone can use in a battle script. I don't know of a different way to do it, so that's why I put it like this. I'm still a novice at php. Will one player have all 3? Attacks spells skills? Or are you going to be asking your db to recognize what your player is THEN pull related database. Secondly, is there a 'spellpoint' system. When a player exhausts their spell points...you'll want your code to recognize it and negate use of the attack/spell/skill, yes? Could you tell me the structure of your Databases plz? For what I have in mind..you may need to add a few things to have it function.. Quote Link to comment https://forums.phpfreaks.com/topic/213168-problem-combining-tables/#findComment-1110011 Share on other sites More sharing options...
katarra Posted September 11, 2010 Author Share Posted September 11, 2010 A player "could" have spells and attacks, yes. When a player purchases/learns a spell/attack, then the `skills` table gets updated with the following information from that `spells` or `attacks` table: (item_id = the spell or attack id#, name = name of the spell or attack, attacks/spells = whatever the thing being purchased is, and then user_id = the person's unique id# that purchased the spell). There is an "energy" row in `spells` and `attacks` so that when a player expends all of their energy, they can't do any more attacking. There is also a `mp` row in `spells` that is associated with each specific spell, so that when you run out of mp, you can't cast anymore. If you want me to copy/paste exactly what the db tables include, I can do that too. Quote Link to comment https://forums.phpfreaks.com/topic/213168-problem-combining-tables/#findComment-1110033 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.