Hi all!

Here we go trying to explain something that I'm not sure I really understand
myself. If this gets horribly confused, let me know and I'll attempt to
clarify.

I have a table which lists all of the skills a user can pick from (I'm
creating a site for a friend's role-playing game as a sort of playground for
myself to try out different techniques). Each skill, as well as some details
about the skill itself, has a series of fields that specify whether this is
a class skill for each class. So, for example, the part of the table might
look something like this:

Skill            |      Fighter |       Druid           |       Wizard  |       Rogue

Alchemy  |      CC              |       CC              |       Yes             |      
 CC
Ride             |      Yes             |       CC              |       CC             
 |       CC
Pick Pockets |  No              |       No              |       No              |      
 Yes

Does this make sense in itself? Each skill can either be a class skill
(Yes), a cross-class skill (CC), or unavailable (No) to each class.

So in the administration side of things, where the game's owner and myself
can fiddle with settings and such, I have a form that allows us to change
the way each class views each skill. So this page is passed the class name
as a URL parameter, and then starts off with the following 2 queries:

        <cfquery name="q_ClassSkill" datasource="#request.dsn#">
                SELECT          SkillName, Untrained, #URL.ClassName# AS SkillType
                FROM                    Skills
                WHERE                   Untrained = Yes
                ORDER BY        SkillName
        </cfquery>

        <cfquery name="q_ClassSkillT" datasource="#request.dsn#">
                SELECT          SkillName, Untrained, #URL.ClassName# AS SkillType
                FROM                    Skills
                WHERE                   Untrained = No
                ORDER BY        SkillName
        </cfquery>

These select first the untrained skills, then the skills which you have to
be trained to use. In each one, it also selects the column that matches the
class name. So if I had clicked on "Fighter", it would select the skill
name, its status as trained or untrained, and the status it has for fighters
(Yes, No, or CC). A form then outputs the skills with a set of three radio
buttons next to each one, and the currently selected radio button is the one
that is equivalent to the status of that skill (Yes, No, or CC).

The following code is for the radio buttons:

<input type="radio" name="#q_ClassSkill.SkillName#" value="Yes" <cfif
q_ClassSkill.SkillType IS "Yes">CHECKED</cfif>>
<input type="radio" name="#q_ClassSkill.SkillName#" value="CC" <cfif
q_ClassSkill.SkillType IS "CC">CHECKED</cfif>>
<input type="radio" name="#q_ClassSkill.SkillName#" value="No" <cfif
q_ClassSkill.SkillType IS "No">CHECKED</cfif>>

This code is looped over along with the skill name field, so it shows the
appropriate value for each skill.

So far so good? This bit seems to work fine. It all displays correctly and
that's fine.

The problem I have (you knew I had to get to it eventually, right?) is in
trying to process the form. I figured that the most appropriate way to
update lots of records in the database was to first put all the data passed
by the form into a structure and then loop over the structure to do the
update. Is this a good idea? Or is there a much better (and hopefully
simpler) way of doing it?

If this is a good idea, then hopefully someone can help me sort out this
little conundrum. So far I have the following code, trying to figure out
what's the skill type (Yes, No, or CC) for each skill.

        <cfquery name="q_ClassSkill" datasource="#request.dsn#">
                SELECT          SkillName, Untrained, #URL.ClassName# AS SkillType
                FROM                    Skills
                ORDER BY        SkillName
        </cfquery>

        <!--- create a structure to hold data --->
        <cfset st_Skills = StructNew()>

        <!--- Loop over the query to put values into structure --->
        <cfloop query="q_ClassSkill">
                <!--- Set SkillType --->
                <cfset FORM.SkillTypeTemp = "#q_ClassSkill.SkillName#">

                <cfif #FORM.SkillTypeTemp# IS "Yes">
                        <cfset variables.SkillType = "Yes">
                <cfelseif #FORM.SkillTypeTemp# IS "CC">
                        <cfset variables.SkillType = "CC">
                <cfelseif #FORM.SkillTypeTemp# IS "No">
                        <cfset variables.SkillType = "No">
                <cfelse>
                        <cfset variables.SkillType = "">
                </cfif>

I tried outputting variables.SkillType, but it was returning no results. I'm
not sure what else I can do to make this happen, although I also believe
that I've been staring at it for far too long. Can anyone else point out
whatever mistakes I'm making, be they in my method or my code?

Thanks, and kudos to anyone who's read this far. ;) Sorry it's so long.

Seona.

Email: [EMAIL PROTECTED]
Mobile: 0407 842 795
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 27/01/2003


---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to