Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630

    rotazione banner senza refresh

    Carissimi,
    ho questo script che interfaccio con il db:
    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
    %>
    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?
    Grazie
    G.

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    La rotazione senza refresh è lato client pertanto se non vuoi ricaricare la pagina devi mettere i banner dentro un iframe e far ricaricare solo quello.

    Roby

  3. #3

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    Grazie per le risposte.
    ALEXBA64 puoi indicarmi come implementarlo in javascript?
    Grazie
    G.

  5. #5
    Fai una banale ricerca su google

    ne trovi uno che sia di tua comprensione e poi te lo personalizzi

  6. #6
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    Grazie per il consiglio, ma avevo bisogno di implementare questo che utlizza il db, altrimenti in javascript ne ho trovati molti.
    Grazie lo stesso
    G.

  7. #7
    Non ho prestato molta attenzione alle tue righe di codice, sono sicuro che lo puoi implementare senza grandi difficoltà ma solo con un po di ingegno.

  8. #8
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    purtroppo ancora non conosco molto di asp, ecco perchè ho chiesto aiuto, perchè ho fatto vari tentativi ma nulla.
    Non potresti aiutarmi tu?
    Grazie
    G.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.