March Madness Page Help please
am 12.02.2005 22:07:18 von Jimmy SmitsHi I am trying to develop a little site for myself an co-workers to enter
our march madness bracket picks. With the tiny little bit of knowledge and
some cutting and pasting I have created a mess that sort of works.
I have a JS form that users can enter all of their own picks. However, when
the picks are entered into my DB the only appear as numbers. There is an
area in the code that refers team #'s but it doesnt quite match what I get
in my dB for instance - kentucky should be 1 and it shows up as 0.
Here is the code - if anyone can throw some tips my way I would really
appreciate it. I have edited out the actual Javascript and the .css styles
and other things that arent applicable (I hope) for easier reading.
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" &
Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "PickEntry") Then
MM_editConnection = MM_NCAA_STRING
MM_editTable = "picks"
MM_editRedirectUrl = "home.asp"
MM_fieldsStr =
"participant|text|PICK1|text|PICK2|text|PICK3|text|PICK4|tex t|PICK5|text|PIC
K6|text|PICK7|text|PICK8|text|PICK9|text|PICK10|text|PICK11| text|PICK12|text
|PICK13|text|PICK14|text|PICK15|text|PICK16|text|PICK17|text |PICK18|text|PIC
K19|text|PICK20|text|PICK21|text|PICK22|text|PICK23|text|PIC K24|text|PICK25|
text|PICK26|text|PICK27|text|PICK28|text|PICK29|text|PICK30| text|PICK31|text
|PICK32|text|PICK33|text|PICK34|text|PICK35|text|PICK36|text |PICK37|text|PIC
K38|text|PICK39|text|PICK40|text|PICK41|text|PICK42|text|PIC K43|text|PICK44|
text|PICK45|text|PICK46|text|PICK47|text|PICK48|text|PICK49| text|PICK50|text
|PICK51|text|PICK52|text|PICK53|text|PICK54|text|PICK55|text |PICK56|text|PIC
K57|text|PICK58|text|PICK59|text|PICK60|text|PICK61|text|PIC K62|text|PICK63|
text|TIEBREAKER|text"
MM_columnsStr =
"Player|',none,''|1|',none,''|2|',none,''|3|',none,''|4|',no ne,''|5|',none,'
'|6|',none,''|7|',none,''|8|',none,''|9|',none,''|10|',none, ''|11|',none,''|
12|',none,''|13|',none,''|14|',none,''|15|',none,''|16|',non e,''|17|',none,'
'|18|',none,''|19|',none,''|20|',none,''|21|',none,''|22|',n one,''|23|',none
,''|24|',none,''|25|',none,''|26|',none,''|27|',none,''|28|' ,none,''|29|',no
ne,''|30|',none,''|31|',none,''|32|',none,''|33|',none,''|34 |',none,''|35|',
none,''|36|',none,''|37|',none,''|38|',none,''|39|',none,''| 40|',none,''|41|
',none,''|42|',none,''|43|',none,''|44|',none,''|45|',none,' '|46|',none,''|4
7|',none,''|48|',none,''|49|',none,''|50|',none,''|51|',none ,''|52|',none,''
|53|',none,''|54|',none,''|55|',none,''|56|',none,''|57|',no ne,''|58|',none,
''|59|',none,''|60|',none,''|61|',none,''|62|',none,''|winne r|',none,''|spre
ad|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ")
values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
">
Thanks for reading
Re: March Madness Page Help please
am 13.02.2005 20:36:11 von McKirahan"Jimmy Smits"
news:8euPd.22394$m22.4810@read1.cgocable.net...
> Hi I am trying to develop a little site for myself an co-workers to enter
> our march madness bracket picks. With the tiny little bit of knowledge and
> some cutting and pasting I have created a mess that sort of works.
>
> I have a JS form that users can enter all of their own picks. However,
when
> the picks are entered into my DB the only appear as numbers. There is an
> area in the code that refers team #'s but it doesnt quite match what I get
> in my dB for instance - kentucky should be 1 and it shows up as 0.
>
> Here is the code - if anyone can throw some tips my way I would really
> appreciate it. I have edited out the actual Javascript and the .css styles
> and other things that arent applicable (I hope) for easier reading.
[snip]
> Thanks for reading
"I have created a mess ..." -- agreed.
Arrays are zero-based; perhaps that's your problem.
You don't have to reinvent the wheel:
March Madness Pools for 2005
http://www.runyourpool.com/ncaa_hoops_info.cfm
Among many Google results...