Carissimi,
ho questo script che interfaccio con il db:
Vorrei implementarlo che la rotazione dei banner non sia ad ogni refresh di pagina ma dopo un tot di secondi in modo random e implementare anche una sorta di data di inizio e data di fine del periodo di pubblicazione del banner, creando naturalmente i campi adatti nel db, potete aiutarmi?codice:<% gblConnectString = "DBQ=" & Server.Mappath("\databases\ads.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};" gblSeparator = "#?|?#" Response.Buffer = True fID = Request.Item("fID") fURL = Request.Item("fURL") fClick = cbool(Request.Item("fClick")) fAdmin = cbool(Request.Item("fAdmin")) fUser = Request.Item("fUser") fpassword = Request.Item("fPassword") fperpage= cint(Request.Item("fperpage")) fcurrentpage = cint(Request.Item("fcurrentpage")) if fcurrentpage = 0 then fcurrentpage = 1 if fperpage = 0 then fperpage = 10 fsortby = Request.Item("fsortby") fordertype = Request.Item("fordertype") if fordertype = "" then fordertype = "ASC" if fsortby = "" then fsortby = "ID" 'on error resume next Set ObjCon = Server.CreateObject("ADODB.Connection") ObjCon.Open gblConnectString,,16 Set Objcmd = Server.CreateObject("ADODB.Command") Objcmd.ActiveConnection = ObjCon if fAdmin = True then showstats fperpage, fcurrentpage, fsortby,fordertype end if if fClick = True and fAdmin = False then AdClicked fID elseif fClick = False And fAdmin = False then Randomize Rand = cint(int(cint(AdCount) * Rnd(47) + 1)) 'Response.Write AdCount LoadAd Rand end if Sub LoadAd(intID) Objcmd.commandtext = "SELECT * FROM ADS WHERE ID=" & intID set ObjRS = Objcmd.Execute IF ObjRS.EOF Then Response.Write("ERROR: EOF") : Exit Sub fID = intID fURL = ObjRS("URL") fURL = mid(fURL,10,len(fURL)-11) fIMG = ObjRS("ImageURL") fTrackURL = ObjRS("TrackURL") fViews = ObjRS("Views") fViews = fViews + 1 Objcmd.commandtext = "UPDATE ADS SET Views=" & fViews & " WHERE ID=" & intID set ObjRS = Objcmd.Execute displayad fID,fIMG,fURL,fTrackURL End Sub Sub AdClicked(intID) Objcmd.commandtext = "SELECT Clicks FROM ADS WHERE ID=" & intID set ObjRS = Objcmd.Execute IF ObjRS.EOF Then Exit Sub fID = intID fClick = ObjRS("Clicks") fClick = cint(fClick) + 1 Response.Write furl Objcmd.commandtext = "UPDATE ADS SET Clicks=" & fClick & " WHERE ID=" & intID set ObjRS = Objcmd.Execute Response.Redirect furl End Sub Sub ShowStats(iPerPage,iCurrentPage,strSortBy, strOrderType) Dim TotalPages TotalPages = cint(Round(AdCount / iPerPage ,0)) Objcmd.commandtext = "SELECT * FROM ADS ORDER BY " & strSortBy & " " & strOrderType set ObjRS = Objcmd.Execute 'Response.Write iperpage & "" & icurrentpage ObjRS.PageSize = iPerPage 'Response.Write TotalPages 'ObjRS.AbsolutePage = iCurrentPage 'Display PREV page link, if appropriate If Not iCurrentPage = 1 Then Response.Write "<div align=center><a href=ad.asp?fordertype=" & strOrdertype & "&fsortby=" & strsortby & "&fcurrentpage=" & iCurrentPage - 1 & "&fAdmin=True&fperpage=10>Prev</a> | " Else Response.Write "<div align=center>Prev | " End If 'Display NEXT page link, if appropriate If cint(iCurrentPage) < TotalPages Then Response.Write "<a href=ad.asp?fordertype=" & strOrdertype & "&fsortby=" & strsortby & "&fcurrentpage=" & iCurrentPage + 1 & "&fAdmin=True&fperpage=10>Next</a> " & vbcrlf & "</div>" Else Response.Write "Next " & vbcrlf & "</div>" End If %> <font size="2" face="Verdana">Displaying page <%=iCurrentPage%> of <%=TotalPages%>: Sorted By <%=strSortBy%>:</font></p> <table align=center border=0 cellpadding=0 cellspacing=0 width="90%"> <tr bgcolor="Silver"> <td align=center> ID </td> <td align=center> Image </td> <td align=center> Views </td> <td align=center> Clicks </td> </tr> <% pCount = (IPerPage * iCurrentPage) Count = ((iperpage * icurrentpage) - iperpage) 'Response.Write pCount & "" & Count ObjRS.Move Count Do While Not ObjRS.EOF and Count < Pcount tID = ObjRS("ID") tIMG = ObjRS("ImageURL") tViews = ObjRS("Views") tClick = ObjRS("Clicks") %> <tr bgcolor="Background"> <td align=center> <%=tID%> </td> <td align=center valign=middle> <%=tIMG%> </td> <td align=center> <%=tViews%> </td> <td align=center> <%=tClick%> </td> </tr> <% objrs.MoveNext Count = Count + 1 Loop %> </table> <% End Sub Sub DisplayAd(intID,strImage,strURL,strTrack) %> <A href="/ads/ad.asp?fID=<%=intID%>&fURL=<%=server.URLEncode(strURL)%>&fClick=True" target="_AD"><%=strImage%> <%=strTrack%><% End Sub Function ADCount() Objcmd.commandtext = "SELECT Views FROM ADS" set ObjRS = Objcmd.Execute AdCount = 0 do while not ObjRS.EOF AdCount = AdCount + 1 ObjRS.MoveNext Loop End Function ObjCon.Close set ObjRS = Nothing Set ObjCon = Nothing Set Objcmd = Nothing %>
Grazie
G.

Rispondi quotando
