ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 14th, 2003, 03:06 PM
aglinx aglinx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 2 aglinx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Topsites help please

This page displays a toplist and it has 50 links per page. The problem is when you go to the next page to see the next 50 links, the count starts out at "11" instead of "51". Can someone please glance at this code and tell me where the problem could be? Also I have a problem where it list a banner that is submitted when someone signs up. If they leave the field blank, then a dead image link shows up on the page. I would really appreciate anybodys help on this. This is the script to show the links and the include file is listed below it:
<%
OPTION EXPLICIT
Response.Buffer = True
%>
<!--#include file="inctopsite.asp"-->
<!--#include file="top.asp"-->

<%
'Some before doings...
Dim oConn, sRubrik
Set oConn = IncTopsite_GetDatabaseConn()

Dim nPageNo, nLastPage
nLastPage = 1
nPageNo = Request.QueryString("pageno")
If nPageNo = "" Then
nPageNo = 1
End If

'Lets get the links
Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset")

Dim sCat
sCat = Request("cat")

Dim strSQL
strSQL = "select site.id as sid, url, sitename, sitedescr, banneraddress, catid, cat.txt as catname, incount, outcount from " & IncTopsite_GetTablePrefix() & "site as site, " & IncTopsite_GetTablePrefix() & "cat as cat where site.catid=cat.id"
If sCat <> "" And CInt(sCat) <> 0 Then
strSQL = strSQL & " AND catid=" & sCat
End If

Set oRS.ActiveConnection = oConn
oRS.CursorLocation = 3
oRS.PageSize=50
oRS.Open strSQL & " order by incount desc",,3,1
If oRS.EOF = False Then
nLastPage=oRS.PageCount
oRS.AbsolutePage = nPageNo
End If
%>


<html>

<head>
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<style type="text/css">
<!--
body { font-family: Verdana,Arial,Helvetica; font-size: smaller; color: #000000}
td { font-family: Verdana,Arial,Helvetica; font-size: smaller; color: #000000}
th { font-family: Verdana,Arial,Helvetica; font-size: smaller; color: #000000}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: underline;}
-->
</style>
</head>

<body bgcolor="<%=g_strBodyColor%>">
<form method="get" action="showlist.asp">
<table width="100%" border="1" cellspacing="1" cellpadding="5" align="center" valign="top"><tr>
<td width="20" align="center" bgcolor="#000000"><font face="Arial" size="3" color="#FFFFFF"><b>Rank</b></font></td>
<td align="center" bgcolor="#000000"><font face="Arial" size="3" color="#FFFFFF"><b>Site</b></font></td>
<td width="20" align="center" bgcolor="#000000"><font face="Arial" size="3" color="#FFFFFF"><b>In</b></font></td>
<td width="20" align="center" bgcolor="#000000"><font face="Arial" size="3" color="#FFFFFF"><b>Out</b></font></td></tr>

<%
Dim sButton, sSiteName, sSiteDescription, sBannerAddress, nCount, sColor, nCatid, sCatName
sColor = g_strSiteBgColor2
Dim nStartNo
nStartNo = (nPageNo * 10) - 10
For nCount=1 To oRS.PageSize
sBannerAddress = ""
sSiteName = ""
sSiteDescription = ""
If oRS.EOF = False Then
nCatid = oRS("catid")
sCatname = oRS("catname")
sBannerAddress = "<a href=" & """" & "goto.asp?id=" & oRS("sid") & """" & " target=_blank>" & "<img src=" & oRS("banneraddress") & " border=0 width=468 height=60>" & "</a>"
sSiteName = "<a href=" & """" & "goto.asp?id=" & oRS("sid") & """" & " target=_blank>" & oRS("sitename") & "</a>"
sSiteDescription = oRS("sitedescr")
If sColor = g_strSiteBgColor2 Then
sColor = g_strSiteBgColor1
Else
sColor = g_strSiteBgColor2
End If

%>

<center>
<table width="100%" cellspacing="2" cellpadding="2" border="1">
<tr>
<td width="44" align="center" bgcolor="#FFFFFF"><%=nStartNo+nCount%></td>
<td align="center" bgcolor="#FFFFFF"><%=sBannerAddress%><BR><%=sSiteName%><BR><%=sSiteDescription%></td>
<td width="24" align="center" bgcolor="#FFFFFF"><%=ors("incount")%></td>
<td width="32" align="center" bgcolor="#FFFFFF"><%=ors("outcount")%></td>
</tr>
</table>


<%
oRS.MoveNext
End If
Next
oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing

Sub WritePrev()
'
If CInt(nPageNo) <> 1 Then
Response.Write "<a href=""showlist.asp?pageno=" & nPageNo-1 & """><img border=0 src=""prevpage.gif""></a>"
End If
End Sub

Sub WriteNext()
'
If CInt(nPageNo) <> CInt(nLastPage) And nLastPage<>0 Then
Response.Write "<a href=""showlist.asp?pageno=" & nPageNo+1 & """><img border=0 src=""nextpage.gif""></a>"
End If
End Sub

%>
<tr>
<td bgColor=<%=g_strBodyColor%> width="50%" align="left"><%WritePrev%></td>
<td bgColor=<%=g_strBodyColor%> width="50%" align="right">
<%WriteNext%></td>

Below is the include file:
<!--#include file="incgenmail.asp"-->
<%

'''' Configuration:
''''1. Database connection
Function IncTopsite_GetDatabaseConn()
Dim oRet
Dim strDSN
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("\../Directory/db/topsite2.mdb")
Set oRet = Server.CreateObject ("ADODB.Connection")
oRet.Open strDSN
Set IncTopsite_GetDatabaseConn = oRet
IncTopsite_PerhapsCleanUp oRet
End Function


'''Configuration:
''''2. Config variables

Const g_strTitle = ""
Const g_strTitle2 = ""
Const g_strPath = ""
Const g_strButtonImagePath = ""
Const g_nSitesPerPage = "50"
Const g_AdminUID = ""
Const g_AdminPassword = ""
Const g_ClickThruPage = True

Const g_MailServer = ""
Const g_OutgoingMailFrom = ""

Const g_strSiteBgColor1 = "#D7D7D7"
Const g_strSiteBgColor2 = "White"
Const g_strBodyColor = "White"



'This variable could be set to
' DAY for hits/day ranking or
' TOTAL for total hits ranking

Const g_strRankOption = "DAY"

'If set to true then clicking will take the user to another page and if he/she clicks
' there a hit will be counted. This is to defeat cheating

Const g_fUseGateway = True





'''Configuration:
''''3. Some ads if you'd like

Function FAQ_GetAd(nNumber)
Select Case nNumber
Case 1
FAQ_GetAd = ""
Case 2
FAQ_GetAd = ""
Case 3
FAQ_GetAd = ""
End Select
End Function

Function IncTopsite_PerhapsCleanUp( oConn )

If g_strRankOption = "TOTAL" Then
IncTopsite_PerhapsCleanUp = False
Exit Function
End If

Dim sNow, sStart, fShouldCleanup
sNow = Now()
sStart = Application("ts_start")
If sStart = "" Then
Dim oRSWhenStart
Set oRSWhenStart = oConn.Execute("select startdate from "& IncTopsite_GetTablePrefix() & "sysvar " )
If oRSWhenStart.EOF Then
oRSWhenStart.Close
Set oRSWhenStart = Server.CreateObject("ADODB.Recordset")
Set oRSWhenStart.ActiveConnection = oConn
oRSWhenStart.Open "select * from " & IncTopsite_GetTablePrefix() & "sysvar where id = -1", ,1,3
oRSWhenStart.AddNew()
oRSWhenStart("startdate") = Now()
oRSWhenStart.Update
oRSWhenStart.Close
Set oRSWhenStart = Nothing
sStart = Application("ts_start")
Exit Function
Else
sStart = oRSWhenStart("startdate")
oRSWhenStart.Close
Set oRSWhenStart = Nothing
End If
End If
fShouldCleanup = False

If ShouldCleanUp( g_strRankOption, sStart, sNow ) = True Then
oConn.Execute("update " & IncTopsite_GetTablePrefix() & "site set incount=0,outcount=0")
Set oRSWhenStart = Server.CreateObject("ADODB.Recordset")
Set oRSWhenStart.ActiveConnection = oConn
oRSWhenStart.Open "select * from " & IncTopsite_GetTablePrefix() & "sysvar", ,1,3
oRSWhenStart("startdate") = Now()
oRSWhenStart.Update
oRSWhenStart.Close
Set oRSWhenStart = Nothing
End If
End Function

Function IncTopsite_GetTablePrefix()
'IncTopsite_GetTablePrefix = ""
IncTopsite_GetTablePrefix = ""
End Function


Function ShouldCleanUp( g_strRankOption, sStart, sNo )
If g_strRankOption = "DAY" Then
If DateDiff( "d", sStart, sNo ) > 1 Then
ShouldCleanUp = True
Exit Function
End If
End If
ShouldCleanUp = False
End Function


Sub ListCategories( nSelected, fListAll )
Dim oRSCats
Dim sSelected
Set oRSCats = oConn.Execute("select id, txt from " & IncTopsite_GetTablePrefix() & "cat order by txt ")
If fListAll = True Then
If nSelected = "" Or CInt(nSelected)=0 Then
sSelected = "selected "
Else
sSelected = ""
End If
Response.Write "<option " & sSelected & "value=""" & "0" & """>" & "All" & "</option>"
End If
While Not oRSCats.EOF
If CInt(nSelected) = CInt(oRSCats("id").Value) Then
sSelected = "selected "
Else
sSelected = ""
End If
Response.Write "<option " & sSelected & "value=""" & oRSCats("id") & """>" & oRSCats("txt") & "</option>"
oRSCats.MoveNext
Wend
oRSCats.Close
Set oRSCats = Nothing
End Sub


'Not working yet
Const g_AdminEmail = "" 'Set this so you will get email when someone has joined the list and validation is needed
Const g_ValidationNeeded = False

%>

Reply With Quote
  #2  
Old April 14th, 2003, 10:17 PM
defjamninja defjamninja is offline
Overly white
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Fresno, CA
Posts: 83 defjamninja User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Code:
<%
Dim sButton, sSiteName, sSiteDescription, sBannerAddress, nCount, sColor, nCatid, sCatName
sColor = g_strSiteBgColor2
Dim nStartNo
nStartNo = (nPageNo * 10) - 10
For nCount=1 To oRS.PageSize
sBannerAddress = ""
sSiteName = ""
sSiteDescription = ""
If oRS.EOF = False Then
nCatid = oRS("catid")
sCatname = oRS("catname")
sBannerAddress = "<a href=" & """" & "goto.asp?id=" & oRS("sid") & """" & " target=_blank>" & "<img src=" & oRS("banneraddress") & " border=0 width=468 height=60>" & "</a>" 
sSiteName = "<a href=" & """" & "goto.asp?id=" & oRS("sid") & """" & " target=_blank>" & oRS("sitename") & "</a>" 
sSiteDescription = oRS("sitedescr")
If sColor = g_strSiteBgColor2 Then
sColor = g_strSiteBgColor1
Else
sColor = g_strSiteBgColor2
End If
%>


The bolded area is your problem. (1*10)-10 = 0, (2*10)-10 = 10.

The easiest way to fix this would be just to pass the count in the url. So in your next page link just put something like
Code:
?Count=<%= Pagenumber + 50%>


For your next question. You have a few options. You could check at sign up and if the banner link is not submitted then ask again for it. Or allow them to submit no banner and check for that on display and if the banner link is blank then don't display the image. Finally you could check on display if the banner link is blank and if it is then display your own default banner.

Personally I would force them to submit a banner link. If you would rather not do that then I would just display my own personal default banner, free advertising for your own site .
Something like this would work.
Code:
<% If len(oRs("banneraddress") = 0 then strBanner = "my banner address" end if %>
"<img src=" & strBanner & " border=0 width=468 height=60>"

OR
Code:
<% If len(oRs("banneraddress") <> 0  then Response.write("<img src=" & strBanner & " border=0 width=468 height=60>") End if %>

Last edited by defjamninja : April 14th, 2003 at 10:32 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Topsites help please

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap