ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2004, 10:37 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
Need a second pair of eyes..

Okay I have two table: items and guildarmory

the items table are the items you own (weapons and armor) it is 'o' if you don't have anything there. slota-slotf

guildarmory table is the weapons and armor it owns. o means nothing there. slota-slotz

Well....

I'm making a query so you can donate to the armory.. so far I have:

<form action="guildarmoryact.cfm?guildid=<cfoutput>#url.guildid#</cfoutput>" method="post">
<cfquery name="getweps" datasource="userlogin">
SELECT * from Items
where user_ID = '#session.user_ID#'
</cfquery>
<SELECT SIZE="1" NAME="donate">
<cfoutput query="getweps">

<CFIF slota is not 'o'>
<OPTION VALUE="#SlotA#">#SlotA#</OPTION>
</CFIF>

all the way through slotf

</cfoutput>

Then the action page is:

<cfquery name="where" datasource="userlogin">
SELECT * from GuildArmory
where guildid = '#URL.guildid#'
</cfquery>
<cfoutput query="where">
<cfif slota is 'o'>

<cfquery name="updatearmory" datasource="userlogin">
update Guildarmory
set SlotA = '#form.donate#'
where guildid = '#URL.guildid#'


</cfquery>
</cfif>


Now.. how in the world would i write a query to subtract it from your items since you donated it? How do i know what slot to subtract it from? it's probably something simple but ive been at iit a while and just need a second pair of eyes please!

Reply With Quote
  #2  
Old November 30th, 2004, 10:46 AM
Ebot's Avatar
Ebot Ebot is offline
Meatball Surgeon
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Elbow deep in code
Posts: 1,398 Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 35858 Folding Title: Starter FolderFolding Points: 35858 Folding Title: Starter Folder
Time spent in forums: 1 Week 5 Days 15 h 23 m 31 sec
Reputation Power: 790
Well even though this really is an SQL question, the answer is pretty easy.

I am assumming each table has a primary key. So once you have selected your item from the 'ITEM' table and added it to the armory table, you should use the ITEM primary key to do an update statement to set whatever columns to 'o' to show you no longer own it; using the primary key in your where clause.

Reply With Quote
  #3  
Old November 30th, 2004, 10:52 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
Quote:
Originally Posted by Ebot
Well even though this really is an SQL question, the answer is pretty easy.

I am assumming each table has a primary key. So once you have selected your item from the 'ITEM' table and added it to the armory table, you should use the ITEM primary key to do an update statement to set whatever columns to 'o' to show you no longer own it; using the primary key in your where clause.




The table is set up like this:
ID - primary
User_ID - 1
SlotA - Weapon
SlotB - o
SLotC - o
SlotD - o
SlotE - o
SlotF - o

When I add it i'm just taking the "weapon" name and not really what slot it came from so i dont know what slot to set to 'o'. Maybe I misunderstand what you're saying. Can i get an example?

Reply With Quote
  #4  
Old November 30th, 2004, 12:01 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
Repeated columns like that are a red flag that something in your design is wrong. What happens if you want to allow a user more weapons, do you keep adding more columns...'WeaponG...WeaponT..."? Also unless all users have all weapons your going to have a ton of empty columns.

What you really want to do is have 3 tables...a user table, a weapon table, and a table that relates users to their weapons.

table user
userID,userName

table weapons
weaponID, weaponName

table users_weapons
userID, weaponID

This way if you have a userID, you can query users_weapons to determine what weaponID's they are associated with.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #5  
Old November 30th, 2004, 12:09 PM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
Well actually they are only allowed to store a certain amount of weapons. Most people generally have 6, but guilds have way more then that, so they are having to get rid of some sometimes. Porbably would be better your way now that I think about it but would it be impossible to do it my way? Not planning on re-coding it all and it works fine for me.


Quote:
Originally Posted by kiteless
Repeated columns like that are a red flag that something in your design is wrong. What happens if you want to allow a user more weapons, do you keep adding more columns...'WeaponG...WeaponT..."? Also unless all users have all weapons your going to have a ton of empty columns.

What you really want to do is have 3 tables...a user table, a weapon table, and a table that relates users to their weapons.

table user
userID,userName

table weapons
weaponID, weaponName

table users_weapons
userID, weaponID

This way if you have a userID, you can query users_weapons to determine what weaponID's they are associated with.

Reply With Quote
  #6  
Old November 30th, 2004, 12:15 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
You're of course free to do it however you want, but this very likely will cause headaches for you down the line.

But to answer the question, no, there's no way to know which slot the weapon came from unless you explicitly keep track of it along with the weapon. An alternative would be to query the table for a user and loop through the weapons for that user until you find which slot the current weapon is in.

Reply With Quote
  #7  
Old November 30th, 2004, 12:31 PM
Ebot's Avatar
Ebot Ebot is offline
Meatball Surgeon
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Elbow deep in code
Posts: 1,398 Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)Ebot User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 35858 Folding Title: Starter FolderFolding Points: 35858 Folding Title: Starter Folder
Time spent in forums: 1 Week 5 Days 15 h 23 m 31 sec
Reputation Power: 790
kiteless it quite right, you really don't want to be designing your database that way (even if you have a limited number of items). Bust out your basic database book and look up 3rd level of normalization, that will put your database on the right path (and save you HUGE headaches in the future.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Need a second pair of eyes..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT