-
1. Re: Insert/Update Individual Fields in DB Table
Eric Cobb Feb 16, 2011 8:31 AM (in response to OgreOne)You only need 1 table to hold the class info. Here's a generic example of how you would run the update statement:
UPDATE yourTableName SET open_seats = open_seats-1 WHERE cid = #yourCID#
That should get you started.
-
2. Re: Insert/Update Individual Fields in DB Table
Dan Bracuk Feb 16, 2011 9:21 AM (in response to OgreOne)A more normalized database design would take away the requirement to do anything.
Consider a design where your table has a capacity field instead of a seats_remaining. Once you set up a class, you might not have to change that value. Then, as people register, you populate a many to many table. Hopefully you are already doing this. Then to see how many spots you have left, you do something like this:
select capacity -
(select count(*)
from your many to many table
where it's this class) seats_remaining
from your class table
where it's this class
-
3. Re: Insert/Update Individual Fields in DB Table
OgreOne Feb 16, 2011 11:02 AM (in response to Dan Bracuk)unfortunately, I kno what a "many to many table" is.
-
4. Re: Insert/Update Individual Fields in DB Table
Dan Bracuk Feb 16, 2011 3:48 PM (in response to OgreOne)If you want to take the time to learn, I've heard good things about the book, Database Design for Mere Mortals.
-
5. Re: Insert/Update Individual Fields in DB Table
OgreOne Feb 21, 2011 2:03 PM (in response to Eric Cobb)okay...So this is what I plugged in:
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ "form1">
<cfquery datasource="illegal">
UPDATE ed.usf_registration
SET #FORM.open_spots# = #FORM.open_spots-1#
WHERE cid=<cfoutput>#Recordset1.cid#</cfoutput>
</cfquery>
</cfif>
<cfquery name="Recordset1" datasource="illegal">
SELECT *
FROM ed.usf_registration
</cfquery>And my form looks like this:
<form action="<cfoutput>#CurrentPage#</cfoutput>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Cid:</td>
<td><cfoutput>#Recordset1.cid#</cfoutput></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Id:</td>
<td><input type="text" name="id" value="<cfoutput>#Recordset1.id#</cfoutput>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Open_spots:</td>
<td><input type="text" name="open_spots" value="<cfoutput>#Recordset1.open_spots#</cfoutput>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="cid" value="<cfoutput>#Recordset1.cid#</cfoutput>" />
<input type="hidden" name="MM_UpdateRecord" value="form1" />
</form>So far, i can't get to work. I do not understand the CF markup as well as I probably should. Can anyone offer some further help? It would be greatly appreciated.


