Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Ezilon Directory   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 03-25-2006, 05:09 PM   #1 (permalink)
Contributing Member
 
I like pie's Avatar
 
Join Date: 10-12-03
Location: California
Posts: 254
iTrader: 0 / 0%
Latest Blog:
None

I like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the rough
Send a message via ICQ to I like pie Send a message via AIM to I like pie Send a message via MSN to I like pie Send a message via Yahoo to I like pie
question about linking tables

Here's the situation:

I have a game, and in this game each player has the oppurtunity to acquire several weapons.

There is a player table, and a weapons table (there's much more, but these are the two that matter right now). How do I go about setting and referencing values for each player? I've been told that linking tables is what i want to do, but i've been googling and i've yet to find out what it is that i need to do, or even where to start.

If I had say... 3 "swords of something or other", how would i store that in the db?
__________________
Foohon Pie Productions
I like pie is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 03-26-2006, 05:11 AM   #2 (permalink)
Technical Support
 
Paul M's Avatar
 
Join Date: 12-14-05
Posts: 128
iTrader: 0 / 0%
Paul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of light
Can a player have more than one weapon at a time ?
Paul M is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-27-2006, 09:27 PM   #3 (permalink)
Contributing Member
 
I like pie's Avatar
 
Join Date: 10-12-03
Location: California
Posts: 254
iTrader: 0 / 0%
Latest Blog:
None

I like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the rough
Send a message via ICQ to I like pie Send a message via AIM to I like pie Send a message via MSN to I like pie Send a message via Yahoo to I like pie
they can have any number of any weapon in their weapons inventory, but they can only have one weapon equipped at any given time

i've since found the solution btw, had to have a friend explain a few things to me. thanks though, if i have more questions i'll come ask again.
__________________
Foohon Pie Productions
I like pie is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-28-2006, 01:02 AM   #4 (permalink)
Contributing Member
 
I like pie's Avatar
 
Join Date: 10-12-03
Location: California
Posts: 254
iTrader: 0 / 0%
Latest Blog:
None

I like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the rough
Send a message via ICQ to I like pie Send a message via AIM to I like pie Send a message via MSN to I like pie Send a message via Yahoo to I like pie
and i'm back again already... i don't mean to ask for others to write my code but i've been reading about table joins for about an hour or two and i'm just getting more confused

ok...

so i have a players table, let's say for now that a row looks like this:

id, name, cash, equipped, str

now there's a weapons table:

id, name, str, description

so... when a player equips let's say... a staff, it would update his equipped field to "staff" and his str field would be the sum of his own str value plus the value in the staff's str field

the only way i can think to do it is to get the weapon str in one query, and assign the value to a variable, and then use that in another query. but that seems really sloppy

i'm entirely lost as to how this query should look, any ideas?
__________________
Foohon Pie Productions
I like pie is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-28-2006, 01:15 AM   #5 (permalink)
Contributing Member
 
WorldwideTrading's Avatar
 
Join Date: 01-22-06
Location: Exeter, East Devon, England, UK
Posts: 768
iTrader: 0 / 0%
Latest Blog:
None

WorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really niceWorldwideTrading is just really nice
Quote:
Originally Posted by I like pie
and i'm back again already... i don't mean to ask for others to write my code but i've been reading about table joins for about an hour or two and i'm just getting more confused

ok...
so i have a players table, let's say for now that a row looks like this:
id, name, cash, equipped, str

now there's a weapons table:
id, name, str, description

so... when a player equips let's say... a staff, it would update his equipped field to "staff" and his str field would be the sum of his own str value plus the value in the staff's str field

the only way i can think to do it is to get the weapon str in one query, and assign the value to a variable, and then use that in another query. but that seems really sloppy

i'm entirely lost as to how this query should look, any ideas?

thats simple. Personally I dont use joins. You can do this using basic sql.

select p.id, p.name, p.cash, p.str, w.id as w_id, w.name as w_name, w.description as w_description
from players p, weapons w
where p.equipped = w.id

You will then get these fields:
id, name, cash, str, w_id, w_name, w_description
Returned from a single query.
WorldwideTrading is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-28-2006, 01:27 AM   #6 (permalink)
Contributing Member
 
I like pie's Avatar
 
Join Date: 10-12-03
Location: California
Posts: 254
iTrader: 0 / 0%
Latest Blog:
None

I like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the rough
Send a message via ICQ to I like pie Send a message via AIM to I like pie Send a message via MSN to I like pie Send a message via Yahoo to I like pie
so it's necessary to select some type of data in its own query before updating?

in other words... i couldn't use these values as reference and update them in a single update query?

something like... update players set players.str = (players.str + weapons.str) where player.id = x and weapons.id = y. i know that looks horrible but i can't explain it too well in regular english
__________________
Foohon Pie Productions
I like pie is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-28-2006, 08:14 PM   #7 (permalink)
Contributing Member
 
I like pie's Avatar
 
Join Date: 10-12-03
Location: California
Posts: 254
iTrader: 0 / 0%
Latest Blog:
None

I like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the roughI like pie is a jewel in the rough
Send a message via ICQ to I like pie Send a message via AIM to I like pie Send a message via MSN to I like pie Send a message via Yahoo to I like pie
well i found the solution:

update users set users.str = users.str + (select weapons.str from weapons where weapons.id = $weaponid) where id = $id;

subselects, i had no idea
__________________
Foohon Pie Productions
I like pie is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
(PHP/Mysql) Question reguarding tables and sharing data between. MephDaddy Coding Forum 3 08-25-2007 01:09 PM
Tables vs divs and boxes in css question Linda in NY Coding Forum 4 03-30-2007 06:44 PM
Linking and PR question fiddlefun Google Forum 6 09-10-2004 07:42 AM
Linking for the sake of linking 88sahara Google Forum 13 05-19-2004 01:27 AM
Question about linking RoN SEO Forum 28 12-04-2003 12:18 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 03:29 PM.
© Copyright 2008 V7 Inc