|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help
Here is my code
[code] <%@LANGUAGE="VBSCRIPT"%> <!--#include file="Connections/conFootball.asp" --> <% Dim rsOrganiser__MMColParam rsOrganiser__MMColParam = "0" If (Request.Form("rbgame") <> "") Then rsOrganiser__MMColParam = Request.Form("rbgame") End If %> <% Dim rsOrganiser Dim rsOrganiser_numRows Set rsOrganiser = Server.CreateObject("ADODB.Recordset") rsOrganiser.ActiveConnection = MM_conFootball_STRING rsOrganiser.Source = "Select * from details as A where A.uin in (select organiser from game as B where B.UIN = " + Replace(rsOrganiser__MMColParam, "'", "''") + ")" rsOrganiser.CursorType = 0 rsOrganiser.CursorLocation = 2 rsOrganiser.LockType = 1 rsOrganiser.Open() rsOrganiser_numRows = 0 %> <% Dim rsGetRows Dim rsGetRows_numRows Set rsGetRows = Server.CreateObject("ADODB.Recordset") rsGetRows.ActiveConnection = MM_conFootball_STRING rsGetRows.Source = "SELECT game.uin, details.forename, details.surname, details.uin, game.date, game.organiser, details.[NT Login] FROM game INNER JOIN (details INNER JOIN teams ON details.uin = teams.player) ON game.uin = teams.game ORDER BY game.uin;" rsGetRows.CursorType = 0 rsGetRows.CursorLocation = 2 rsGetRows.LockType = 1 rsGetRows.Open() rsGetRows_numRows = 0 %> <% Dim Repeat1__numRows Dim Repeat1__index Repeat1__numRows = -1 Repeat1__index = 0 rsGetRows_numRows = rsGetRows_numRows + Repeat1__numRows %> <% Dim playerCount 'DEBUG: playerCount value will be set by count of records in the recordset 'Ive just set it to 10 for the moment playerCount=10 Dim arrPlayer ReDim arrPlayer(playerCount-1) 'Grab players firstname and surname from the recordset, to populate the arrPlayer array 'For now Ive just created 10 arrPlayer(0)="player1" arrPlayer(1)="player2" arrPlayer(2)="player3" arrPlayer(3)="player4" arrPlayer(4)="player5" arrPlayer(5)="player6" arrPlayer(6)="player7" arrPlayer(7)="player8" arrPlayer(8)="player9" arrPlayer(9)="player10" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Team Listing Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="scripts/Style1a.css" rel="stylesheet" type="text/css"> </head> <body> <table width="740" border="1" align="center"> <tr> <td height="20" colspan="5"><!--#include file="Head.asp" --></td> </tr> <tr> <td width="150"> </td> <td width="10"> </td> <td width="400"> <form method="get" name="frmRandom" id="frmRandom"> <br> <% While ((Repeat1__numRows <> 0) AND (NOT rsGetRows.EOF)) %> <%=(rsGetRows.Fields.Item("forename").Value)%> <%=(rsGetRows.Fields.Item("surname").Value)%><br> <% Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 rsGetRows.MoveNext() Wend %><br> <br> <% Dim iLoop Response.Write "<strong>Players signed up for this game:</strong><br>" For iLoop = LBound(arrPlayer) to UBound(arrPlayer) Response.Write arrPlayer(iLoop) & "<BR>" Next Response.Write "<br>" Function Jumble(ByVal aArray) Dim iUpper, iLower, iLoop, iSwapPos, varTmp iUpper = UBound(aArray) iLower = LBound(aArray) Randomize Timer For iLoop = iLower to iUpper iSwapPos = Int(Rnd * (iUpper + 1)) varTmp = aArray(iLoop) aArray(iLoop) = aArray(iSwapPos) aArray(iSwapPos) = varTmp Next Jumble = aArray End Function Dim arrNumbers ReDim arrNumbers(playerCount-1) For i=0 to playerCount-1 arrNumbers(i)=i+1 Next 'DEBUG: Display the array in-order 'For iLoop = LBound(arrNumbers) to UBound(arrNumbers) 'Response.Write arrNumbers(iLoop) & "...<BR>" 'Next 'response.write "<P>" 'DEBUG: Jumble array and display the new order arrNumbers = Jumble(arrNumbers) arrNumbers = Jumble(arrNumbers) Response.Write "<strong>Reorder....</strong><br>" For iLoop = LBound(arrNumbers) to UBound(arrNumbers) Response.Write arrNumbers(iLoop) & "<BR>" Next Response.Write "<br>" Response.Write "<strong>Which corresponds to....</strong><br>" For iLoop = LBound(arrNumbers) to UBound(arrNumbers) arrNumbers(iLoop) = arrPlayer(arrNumbers(iLoop) - 1) Response.Write arrNumbers(iLoop) & "<br>" Next %> <input type="submit" name="Randomize" value="Randomize Teams" onClick="Jumble"> </form></td> <td width="10"> </td> <td width="170"> </td> </tr> </table> </body> </html> <% rsOrganiser.Close() Set rsOrganiser = Nothing %> <% rsGetRows.Close() Set rsGetRows = Nothing %> [code] I need help with my players array I don't know how to retrieve them from my database as well as the player count for each game set up. Could anyone provide assistance |
|
#2
|
||||
|
||||
|
You should have posted this in the ASP section.
__________________
Keep it Prodigy, Keep it Real |
|
#3
|
|||
|
|||
|
Sorry posted there now.
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|