%@ Language=VBScript %> <% dim key, theSearchRS2, intSecondRS2 dim pid, MyValue, booSearch booSearch = False if Request.querystring("pid") = "" then pid = Request.form("pid") else pid = Request.querystring("pid") end if category = Request.Form("category") cs = Application("cs_ConnectionString") if (Request.Form("Search")="Search") then doSearch strSQL = "SELECT * FROM photoMain WHERE photoID = " & pid & ";" elseif (Request.Form("Random")="Random") Then getRandom strSQL = "SELECT * FROM photoMain WHERE photoID = " & pid & ";" elseif not (pid = "") then strSQL = "SELECT * FROM photoMain WHERE photoID = " & pid & ";" else pid = "x" strSQL = "SELECT photoMain.* FROM photoMain INNER JOIN vote ON photoMain.photoID = vote.photoID ORDER BY [vote]![theVote]/[vote]![numberOfVotes] DESC;" end if if not pid = "" then Set oRS = Server.CreateObject("ADODB.Recordset") oRS.Open strSQL, cs,,, adCmdText If Not oRS.EOF then oRS.MoveFirst End IF Record = oRS.getRows(1) oRS.Close set oRS = Nothing '0 - photoID '1 - photoName '2 - photoWidth '3 - photoHeight '4 - photoTitle '5 - photoKeywords '6 - photoComments '7 - photoInitialValue '8 - lastModifiedDate '9 - category end if If Request.Form("radButt")="Vote" then strSQL = "SELECT * FROM vote WHERE photoID = " & pid & ";" Set oRS1 = Server.CreateObject("ADODB.Recordset") oRS1.Open strSQL, cs, adOpenKeyset,adLockPessimistic, adCmdText if Request.form("radbutt1") then theRadio = Request.Form("radbutt1") theVote = oRS1.Fields.item("theVote") numberOfVotes = oRS1.Fields.item("numberOfVotes") theVote = theVote + theRadio numberOfVotes = numberOfVotes + 1 oRS1.Fields("theVote") = theVote oRS1.Fields("numberOfVotes") = numberOfVotes oRS1.Update end if oRS1.close set oRS1 = Nothing end if sub getRandom strSQLRandom = "SELECT * FROM photoMain;" Set oRSRandom = Server.CreateObject("ADODB.Recordset") oRSRandom.Open strSQLRandom, cs,,, adCmdText If Not oRSRandom.EOF then oRSRandom.MoveFirst End IF arrRandom = oRSRandom.getRows() intCount = UBound(arrRandom,2) Randomize ' Initialize random-number generator. myValue = Int((intCount+1) * Rnd) ' Generate random value. pid = arrRandom(0,myValue) oRSRandom.Close set oRSRandom = Nothing end sub sub doSearch if not category = "?" then strSQLSearch = "SELECT * FROM photoMain INNER JOIN vote ON photoMain.photoID = vote.photoID WHERE category = '" & category & "' ORDER BY [vote]![theVote]/[vote]![numberOfVotes] DESC;" else strSQLSearch = "SELECT * FROM photoMain INNER JOIN vote ON photoMain.photoID = vote.photoID ORDER BY [vote]![theVote]/[vote]![numberOfVotes] DESC;" end if Set oRS2 = Server.CreateObject("ADODB.Recordset") oRS2.Open strSQLSearch, cs,,, adCmdText If Not oRS2.EOF then oRS2.MoveFirst End IF key = LCase(trim(Request.Form("keyword"))) if not oRS2.EOF then theSearchRS2 = oRS2.getRows() intFirstRS2 = UBound(theSearchRS2,1) '9 intSecondRS2 = UBound(theSearchRS2,2) '4 pid = theSearchRS2(0,0) booSearch = True end if end sub %>