Avatar billede wmahitlist Nybegynder
14. februar 2002 - 10:35 Der er 4 kommentarer og
2 løsninger

Nyeste 5

Jeg har et forum som includer en INC-fil. Jeg skal i dette tilfælde vise de 5 nyeste indlæg, som man skulle kunne trykke på en af de 5 og så kunne besvare spørgsmålet:

default filen (kaldt last5forum.asp) ses her:

<%Option Explicit%>
<!--#include file="last5forum.inc" -->
<!--#include file="forum/boardx/utilities.inc" -->

<%
'connect to the database

  Set dbRS = Server.CreateObject("ADODB.Recordset")
  With dbRS
    .CursorLocation = 3
    .CacheSize = C_dbPageSize
    .Open strSQL, C_dbConnect
  End With

  If dbRS.EOF = False Then
    With dbRS
      .MoveFirst
      topicCount = CInt(.RecordCount)
      .PageSize = C_dbPageSize
      pageCount = CInt(.PageCount)
      .AbsolutePage = curPage
    End With
  Else
    topicCount = 0
    pageCount = 1
  End If

'preconstruct query strings to keep things simple

  stateQS = "curPage=" & curPage & "&"
  stateQS = stateQS & "search="  & Server.URLEncode(strSearch)
%>



<html>
<head>
<meta name="Description" content=":: WMA Forum ::">
<meta name="Keywords" content="wmaforum wma wmadebat debatforum wmaspørgsmål">
<title><%=C_PageTitle%> :: Emner</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--#include file="forum/boardx/javascript.inc" -->
<!--#include file="forum/boardx/style.inc" -->
</head>

<%=C_PageBody%>
<%=C_PageLogo%>
<br>
<p>
<br>
<br>
<table border="0" cellspacing="1" cellpadding="2" width="100%">
  <%
  If dbRS.EOF Then
  %>
  <%
  Else
  Do Until dbRS.EOF Or x >= C_dbPageSize
  %>
    <tr>
      <td width="<%=fieldWidths(0)%>" valign="top"><a href="forum/boardx/read.asp?ID=<%
      If dbRS("parentID") = 0 Then
        Response.Write dbRS("ID")
      Else
        Response.Write dbRS("parentID")
      End If
      %>&<%=stateQS%>"><%=db2web(dbRS("topic"))%></a></td>
      <td width="<%=fieldWidths(1)%>" valign="top"><%=db2web(dbRS("author"))%></td>
      <td width="<%=fieldWidths(2)%>" valign="top"><%=FormatDateTime(dbRS("date_posted"),2)%></td>
      <td width="<%=fieldWidths(3)%>" valign="top"><%
      If dbRS("parentID") = 0 Then
        Response.Write dbRS("replies")
      Else
        Response.Write "-"
      End If
      %></td>
    </tr>
  <%
    x = x + 1
    dbRS.MoveNext
  Loop
  End If
  %>
</table>
<br>
<p>
<br>
</html>

<%
'clear recordset from memory

  Set dbRS = Nothing

'store sort settings in session variables

  Session("sortBy") = sortBy
  Session("sortDir") = sortDir
%>

Skriver lige INC filen i næste felt!

Avatar billede wmahitlist Nybegynder
14. februar 2002 - 10:36 #1
Denne INC-fil hedder last5forum.INC

<%
'Configuration for Asp BoardX - Version 1.0 Beta 1
'created by Mainstream Design
'http://www.mainstreamdesign.com


' ----- DATABASE SETUP -----

  'database settings: modify how the database is accessed

  '-----------------------------------------------------
  'CRUCIAL SETTING: get this wrong and nothing will work
  '-----------------------------------------------------
  CONST C_dbConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:/web/wmahitlist.dk/_private/forum/boardx.mdb"

  'Run GetDBPath.asp in the database directory if you're
  'not sure of the full path to your database file. You
  'can also use a DSN connection string if you set up a DSN
  'for the database.

  CONST C_dbPageSize = 5 'the number of topics to display per page

' ----- TOPIC POSTING SETUP -----

  'required fields: specify what fields are required when posting a topic (Yes or No)

  CONST C_Req_Topic = "Yes" 'require a Topic name
  CONST C_Req_Name = "Yes" 'require a name or alias
  CONST C_Req_Email = "No" 'require an email address
  CONST C_Req_Body = "Yes" 'require the body of the topic to be completed

' ----- APPEARANCE -----

  '--== General Settings ==--

  'page settings: modify the body tag to edit font bg colour, font colour, etc.

  CONST C_PageTitle = ":: WMA FORUM ::"
  CONST C_PageBody = "<body bgcolor=""#FFFFFF"" text=""#000000"" link=""#4263A5"" vlink=""#999999"" alink=""#000000"">"
  CONST C_PageTableBG = "#000000" 'this is the border colour of the tables
  CONST C_PageLogo = "<img src='picture/bund.gif'><font color='#FFFFFF'>Forum</font>" 'can be text or an image

  'font: this will set the font for all elements

  CONST C_PageFont = "Verdana, Arial, Helvetica, sans-serif"
  CONST C_PageFontSize = 8 'pt

  'links: modify how links are displayed

  CONST C_LinksHover = "#4263A5" 'hover colour displays only in IE

  '--== Specific Settings ==--

  'read.asp: modify the colours of the headers which contain
  '          the subject, author name and date posted information

  'colours for the original post
  CONST C_Read_1 = "#4263A5" 'typically a lighter shade of the colour below
  CONST C_Read_2 = "#4263A5"
  CONST C_Read_3 = "#FFFFFF" 'text colour

  'colours for replies
  CONST C_Read_4 = "#000000" 'typically a lighter shade of the colour below
  CONST C_Read_5 = "#FFFFFFF"
  CONST C_Read_6 = "#000000" 'text colour
%>
Avatar billede terry Ekspert
14. februar 2002 - 10:41 #2
vmahitlist>This is more an ASP question isnt it?

To slect the newest 5 records from a table you use TOP 5 in your select
example.

ELECT TOP 5
FirstName, LastName
FROM Students
WHERE GraduationYear = 1994
ORDER BY DateCreated DESC;
Avatar billede terry Ekspert
14. februar 2002 - 11:06 #3
well either move your question to ASP or tell me why you reject the answer or we have no way of helping you
Avatar billede wmahitlist Nybegynder
14. februar 2002 - 11:16 #4
How do i move it to ASP
Avatar billede terry Ekspert
14. februar 2002 - 11:25 #5
close the question and open it again under ASP
You need to place an answer and accept it!
Avatar billede wmahitlist Nybegynder
14. februar 2002 - 11:29 #6
Moving this to ASP, sorry!
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
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

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