Forums
This topic is locked
Link visits Error please Help.
Posted 24 Sep 2008 09:18:00
1
has voted
24 Sep 2008 09:18:00 Ishfaak Aha posted:
Hi can some one please help me to sort this pelase.....I got this code and it has made the primary key as URL and this way is not the best So I added a ID field to that I can modyfy by the id to check the "Links Views or Hits". THsi works, and goes to the desired page with the line (redirect.asp?url=) whick redirects to to get the No of views per link and goes to the link.
<a href="Javascript<img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>opdbDes('redirect.asp?url=viewdiscription.asp?ID=<%=(rsClicks.Fields.Item("ID".Value)%>')">More</span></a>
The page begins with clickview.asp: the only thing is when include the ID as the primary key the views are added when click, but it adds a extra table or column each time the link is clicked, with a different location, what do I have to do if to add this to a ID please?
Here is the code: clickview.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim MM_connClicks_STRING
MM_connClicks_STRING = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("clickcounts.mdb")
%>
<%
Dim rsClicks
Dim rsClicks_numRows
Set rsClicks = Server.CreateObject("ADODB.Recordset"
rsClicks.ActiveConnection = MM_connClicks_STRING
rsClicks.Source = "SELECT * FROM SiteClicks"
rsClicks.CursorType = 0
rsClicks.CursorLocation = 2
rsClicks.LockType = 1
rsClicks.Open()
rsClicks_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rsClicks_numRows = rsClicks_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
Dim rsClicks_total
Dim rsClicks_first
Dim rsClicks_last
'set the record count
rsClicks_total = rsClicks.RecordCount
' set the number of rows displayed on this page
If (rsClicks_numRows < 0) Then
rsClicks_numRows = rsClicks_total
Elseif (rsClicks_numRows = 0) Then
rsClicks_numRows = 1
End If
' set the first and last displayed record
rsClicks_first = 1
rsClicks_last = rsClicks_first + rsClicks_numRows - 1
' if we have the correct record count, check the other stats
If (rsClicks_total <> -1) Then
If (rsClicks_first > rsClicks_total) Then
rsClicks_first = rsClicks_total
End If
If (rsClicks_last > rsClicks_total) Then
rsClicks_last = rsClicks_total
End If
If (rsClicks_numRows > rsClicks_total) Then
rsClicks_numRows = rsClicks_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them
If (rsClicks_total = -1) Then
' count the total records by iterating through the recordset
rsClicks_total=0
While (Not rsClicks.EOF)
rsClicks_total = rsClicks_total + 1
rsClicks.MoveNext
Wend
' reset the cursor to the beginning
If (rsClicks.CursorType > 0) Then
rsClicks.MoveFirst
Else
rsClicks.Requery
End If
' set the number of rows displayed on this page
If (rsClicks_numRows < 0 Or rsClicks_numRows > rsClicks_total) Then
rsClicks_numRows = rsClicks_total
End If
'set the first and last displayed record
rsClicks_first = 1
rsClicks_last = rsClicks_first + rsClicks_numRows - 1
If (rsClicks_first > rsClicks_total) Then
rsClicks_first = rsClicks_total
End If
If (rsClicks_last > rsClicks_total) Then
rsClicks_last = rsClicks_total
End If
End If
%>
<html>
<head>
<title>Clickthroughs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function mark(face,field_color,text_color){
if (document.documentElement){//if browser is IE5+ or NS6+
face.style.backgroundColor=field_color;
face.style.color=text_color;
}
}
//-->
</script>
<style type="text/css">
<!--
a {
font-family: Tahoma;
color: #000000;
text-decoration: none;
}
a:hover {
font-family: Tahoma;
color: #FF0000;
text-decoration: none;
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function PopdbDes(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=425,height=438,left = 330,top = 213');"
}
// End -->
</script>
</head>
<body>
<div align="center"><strong><font size="4" face="Tahoma"> Website Click through for edit</font></strong></div>
<div align="center"><br>
<table width="65%" border="0">
<tr>
<td> <div align="right"><font size="1" face="Tahoma">
Showing a total of : <%=(rsClicks_total)%> links </font></div></td>
</tr>
</table>
<table width="65%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td>
<table width="699" border="0" cellspacing="1">
<tr bgcolor="#3399CC">
<td width="21%"> <font color="#FFFFFF">Name</font></td>
<td width="15%"> <font color="#FFFFFF">Position</font></td>
<td width="11%"> <font color="#FFFFFF">Salary</font></td>
<td width="14%" align="center">
<font face="Times New Roman">URL</font></td>
<td width="8%">
<b>
<font face="Arial" size="2" color="#FFFFFF">Age</font></b></td>
<td width="25%"> <div align="center"><font color="#FFFFFF" size="2" face="Tahoma">
<strong>Click through for Description</strong></font></div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsClicks.EOF))
%>
<tr bgcolor="#FFFFFF" onMouseOver="mark(this,''#FFFF99'',''#000000'')"
onMouseOut="mark(this,''#FFFFFF'',''#000000'')">
<td width="21%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBName".Value)%></font></td>
<td width="15%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBposition".Value)%></font></td>
<td width="11%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBsalary".Value)%></font></td>
<td width="14%" align="center"><a href="redirect.asp?url=<%=(rsClicks.Fields.Item("URL".Value)%>" target="_blank">
<font face="Arial" size="1"><%=(rsClicks.Fields.Item("URL".Value)%></font></a></td>
<td width="8%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBage".Value)%></font></td>
<td width="25%">
<p align="center"><font face="Arial" size="1"><span style="font-size: 8.0pt; font-family: Arial">More</span></a>
<b><font color="#FF6600">(</font></b>views:<%=(rsClicks.Fields.Item("ClickCount".Value)%><b><font color="#FF6600"><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle></font></b></span></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsClicks.MoveNext()
Wend
%>
</table></td>
</tr>
</table>
</div>
</body>
</html>
<%
rsClicks.Close()
Set rsClicks = Nothing
%>
The redirect redirect.asp code is:
<%
SiteURL = Request.QueryString("URL"
If Len(SiteURL) > 0 Then
Set objConn = CreateObject("ADODB.Connection"
objConn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/view-addeddw/clickcounts.mdb" & ";Persist Security Info=False"
' If the URL is already in the database an error will be thrown and we perform an UPDATE Instead of a INSERT.
on error resume next
objConn.Execute "INSERT INTO SiteClicks(URL,ClickCount) VALUES('" & SiteURL & "',1)"
If Err.Number <> 0 Then
objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE URL='" & SiteURL & "'"
End If
objConn.Close
Set objConn= Nothing
Response.redirect SiteURL
End If
'End If
%>
Can Some one please help me to sort this by ID.
Awaiting your favorable reply.
Thank you.
Hello