Avatar billede Slettet bruger
09. august 2003 - 15:39 Der er 7 kommentarer og
1 løsning

siden er læst X gange hvordan bygger jeg det ind i mit script

Jeg sidder og er ved at bygge om på et script. Nederst på siden af dette script vil jeg gerne have et script ind hvor der står hvor mange gange siden er læst X gange.
Er der en der kan foræltte mig hvordan jeg bygger det ind i mit script?
Jeg har forsøgt mig lidt frem men det vil ikke som jeg vil.


<% Option Explicit %>
<!--#include file="common.asp" -->
<%
Dim rsJournal            'Database recordset holding the Journal items
Dim rsCommentsCount        'Database recordset holding the count of comments for each Journal item
Dim rsViewCounter        'Database recordset holding the count of visning af siden
Dim intRecordPositionPageNum    'Holds the number of the page the user is on
Dim intRecordLoopCounter    'Loop counter to loop through each record in the recordset
Dim intTotalNumJournalEntries    'Holds the number of Journal Items there are in the database
Dim intTotalNumJournalPages    'Holds the number of pages the Journal Items cover
Dim intLinkPageNum        'Holds the number of the other pages of Journal itmes to link to


'If this is the first time the page is displayed then set the record position is set to page 1
If Request.QueryString("PagePosition") = "" Then
    intRecordPositionPageNum = 1

'Else the page has been displayed before so the Journal item record postion is set to the Record Position number
Else
    intRecordPositionPageNum = CInt(Request.QueryString("PagePosition"))
End If
%>
<html>
<head>
<title>Journal</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<!-- #include file="header.inc" -->

<div align="center"><span class="heading" style="font-size: <% = intHeadingTextSize + 2 %>px;">Journal</span><br>
  <a href="../default.asp" target="_self">Return to the homepage</a><br>
  <%
'Create recorset object
Set rsJournal = Server.CreateObject("ADODB.Recordset")
   
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblJournal.* FROM tblJournal ORDER BY Date_stamp DESC;"

'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
rsJournal.CursorType = 3
   
'Query the database
rsJournal.Open strSQL, adoCon

'Set the number of records to display on each page by the constant set in the common.asp file
rsJournal.PageSize = intRecordsPerPage
   
'Get the record poistion to display from
If NOT rsJournal.EOF Then rsJournal.AbsolutePage = intRecordPositionPageNum


'Create recorset object
Set rsCommentsCount = Server.CreateObject("ADODB.Recordset")
       

'If there are no rcords in the database display an error message
If rsJournal.EOF Then
    'Tell the user there are no records to show
    Response.Write "<span class=""text""><br>There are no Journal Items to read"
    Response.Write "<br>Please check back later</span>"
    Response.End
   


'Display the Journal Items
Else   
   
    'Count the number of Journal Items database
    intTotalNumJournalEntries = rsJournal.RecordCount   
   
    'Count the number of pages of Journal Items there are in the database calculated by the PageSize attribute set above
    intTotalNumJournalPages = rsJournal.PageCount


    'Display the HTML number number the total number of pages and total number of records
    %>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td align="center" class="text"> <br>
      There are <% = intTotalNumJournalEntries %> Journal Items in <% = intTotalNumJournalPages %> pages and your are on page number <% = intRecordPositionPageNum %>
    </td>
  </tr>
</table>
<br>
<%

    'For....Next Loop to display the Journal Items in the database
    For intRecordLoopCounter = 1 to intRecordsPerPage

        'If there are no records then exit for loop
        If rsJournal.EOF Then Exit For
       
        'Get the count of comments from the db
        strSQL = "SELECT Count(tblComments.Journal_ID) AS CountOfJournalItems "
        strSQL = strSQL & "FROM tblComments "
        strSQL = strSQL & "WHERE tblComments.Journal_ID = " & CLng(rsJournal("Journal_ID")) & ";"
               
        'Query the database
        rsCommentsCount.Open strSQL, adoCon
   
    %>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="<% = strTableBorderColour %>">
  <tr>
    <td> <table width="100%" border="0" cellspacing="1" cellpadding="3">
        <tr>
          <td bgcolor="<% = strTableTitleColour %>" class="heading"><font size="2" face="Verdana" color="#FFFFFF"><% = rsJournal("Journal_title") %></font></td>
        </tr>
        <tr>
          <td bgcolor="<% = strTableColour %>" class="text"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="text"><% = rsJournal("Journal_item") %>
                </td>
              </tr>
              <tr>
                <td align="right" class="smText" height="20">Skrevet af <%
                 
                'If there is an email address entered make it a mailto link
          If rsJournal("Author_email") <> "" Then Response.Write("<a href=""mailto:" & rsJournal("Author_email") & """ style=""font-size: " & intSmallTextSize & "px;"">" & rsJournal("Author") & "</a>") Else Response.Write(rsJournal("Author"))
   
                  %> dato <% = FormatDateTime(rsJournal("Date_stamp"), vbLongDate) %> Kl. <% = FormatDateTime(rsJournal("Date_stamp"), vbShortTime) %><%
                 
        'If commets are allowed for this itm show a links to the comments page
        If CBool(rsJournal("Comments")) = True Then 
                 
                  %>
                  <a href="journal_comments.asp?JournalID=<% = rsJournal("Journal_ID") %>&PagePosition=<% = intRecordPositionPageNum %>" target="_self" style="font-size: <% = intSmallTextSize %>px">Kommentar</a>
                  <%
                                                                         
                    If NOT rsCommentsCount.EOF Then
                        Response.Write "(" & rsCommentsCount("CountOfJournalItems") & ")"
                    Else
                        Response.Write "(0)"
                    End If
        End If
                    %>
Læst antal gange:
<%
                                                                         
                    If NOT rsViewCounter.EOF Then
                        Response.Write "(" & rsViewCounter("ViewCounter") & ")"
                    Else
                        Response.Write "(0)"
                    End If
                    %>
                  </td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<br>
<%
        'Close the count recordset
        rsCommentsCount.Close
       
        'Move to the next record in the recordset
        rsJournal.MoveNext
    Next
End If

'Display an HTML table with links to the other Journal Items
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td> <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="50%" align="center" class="text">
            <%
'If there are more pages to display then add a title to the other pages
If intRecordPositionPageNum > 1 or NOT rsJournal.EOF Then
    Response.Write vbCrLf & "        Page:&nbsp;"
End If

'If the Journal Items page number is higher than page 1 then display a back link       
If intRecordPositionPageNum > 1 Then
    Response.Write vbCrLf & "        <a href=""default.asp?PagePosition=" &  intRecordPositionPageNum - 1  & """ target=""_self"">&lt;&lt;&nbsp;Prev</a>&nbsp;"             
End If       


'If there are more pages to display then display links to all the pages
If intRecordPositionPageNum > 1 or NOT rsJournal.EOF Then
   
    'Display a link for each page in the Journal Items       
    For intLinkPageNum = 1 to intTotalNumJournalPages       
       
        'If the page to be linked to is the page displayed then don't make it a hyper-link
        If intLinkPageNum = intRecordPositionPageNum Then
            Response.Write vbCrLf & "            " & intLinkPageNum
        Else
       
            Response.Write vbCrLf & "            <a href=""default.asp?PagePosition=" &  intLinkPageNum  & """ target=""_self"">" & intLinkPageNum & "</a>&nbsp;"           
        End If
    Next
End If


'If it is Not the End of the Journal Items entries then display a next link for the next Journal Items page         
If NOT rsJournal.EOF then     
    Response.Write vbCrLf & "        <a href=""default.asp?PagePosition=" &  intRecordPositionPageNum + 1  & """ target=""_self"">Next&nbsp;&gt;&gt;</a>"         
End If         


'Finsh HTML the table
%>
          </td>
        </tr>
      </table>
      </td>
  </tr>
</table>
<br>
<br>
<%

'Reset server objects
rsJournal.Close
Set rsJournal = Nothing
Set rsCommentsCount = Nothing
Set strCon = Nothing
Set adoCon = Nothing
%>
<div align="center">
  <%
'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
If blnLCode = True Then
    Response.Write("<span class=""text"" style=""font-size:11px"">Powered by <a href=""http://www.webwizguide.info"" target=""_blank"" style=""font-size:11px"">Web Wiz Journal</a> version 1.0</span>")
    Response.Write("<br><span class=""text"" style=""font-size:11px"">Copyright &copy;2001-2002 Web Wiz Guide</span>")
End If
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
%>
</div>
<!--#include file="footer.inc" -->

Når jeg ligger den ud på min side får jeg denne fejl:
Microsoft VBScript runtime error '800a01a8'

Object required: ''

/test/default.asp, line 139
Avatar billede eagleeye Praktikant
09. august 2003 - 15:43 #1
Den fejl kommer fordi du bruger et object som ikke er oprette som object

Hvad står der i linje 139?
Avatar billede Slettet bruger
09. august 2003 - 15:45 #2
If NOT rsViewCounter.EOF Then
Avatar billede Slettet bruger
09. august 2003 - 15:46 #3
hov kom til at trykke for hurtig ;-)
i linje 139 står der If NOT rsViewCounter.EOF Then
Avatar billede eagleeye Praktikant
09. august 2003 - 15:53 #4
Så er rsViewCounter nok ikke defineret som et recorset.

Det er i dette kode så:

                    If NOT rsViewCounter.EOF Then
                        Response.Write "(" & rsViewCounter("ViewCounter") & ")"
                    Else
                        Response.Write "(0)"
                    End If


Der mangler en SQL sætning som hendter antallet fra databsen, så vidt jeg kan se bliver er kun forsøgt at udskrive antallet. Eller er der noget i dine include filer som hendter det antal??

Jeg ville forvendte nogle linjer som disse inde den if sætning:

SQL = "SELECT * FROM viewCounterTabel WHERE ID = " & id
Set rsViewCounter = CONNOBJ.Execute (SQL)
Avatar billede Slettet bruger
09. august 2003 - 16:16 #5
Hvis jeg forstår det rigtig så skal sætte SQL = "SELECT * FROM viewCounterTabel WHERE ID = " & id
Set rsViewCounter = CONNOBJ.Execute (SQL) ind i scriptet før sætningen med If NOT rsViewCounter.EOF Then
                        Response.Write "(" & rsViewCounter("ViewCounter") & ")"
                    Else
                        Response.Write "(0)"
                    End If
Avatar billede eagleeye Praktikant
09. august 2003 - 16:20 #6
Ja så skal de se sådan her ud, hvor variablen id er den record som skal vises viwecount for, det skal nok være et andet variable navn så du får valgt den rigtige vare:


                    SQL = "SELECT * FROM viewCounterTabel WHERE ID = " & id
                    Set rsViewCounter = CONNOBJ.Execute (SQL)

                    If NOT rsViewCounter.EOF Then
                        Response.Write "(" & rsViewCounter("ViewCounter") & ")"
                    Else
                        Response.Write "(0)"
                    End If
Avatar billede Slettet bruger
09. august 2003 - 16:35 #7
det vil sige id = Journal_ID hmmm måske det ville være nemmere at jeg sendte scriptet til dig så du kan se databasen :) ?
Avatar billede Slettet bruger
24. november 2003 - 00:21 #8
.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester