<%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <% '***** dim boks dim errorkod dim search dim what Boks = Request.querystring ("Boks") search = Request.form ("search") If Search = "" then search = request.querystring ("search") end if what = request.querystring ("what") ''****************Om elelr inte ? If search = "" then What = search else What = what End if Errorkod = request.querystring ("errorkod") IF Boks = "" then Dim strSQL 'En case sats här som fixar och trixar lite grann. IF search <> "" then strSQL = "SELECT * FROM comments where Rubrik like '%"&search&"%' or lag like '%"&search&"%' or Text like '%"&search&"%' ORDER BY datum desc" ELSE strSQL ="SELECT * FROM comments ORDER BY datum desc" END IF Else ' på boks strSQL = "SELECT * FROM comments where Rubrik ORDER BY datum desc" End if ' en if på boks '**** 'Set how many records per page we want Const NumPerPage = 10 'Retrieve what page we're currently on Dim CurPage If Request.QueryString("CurPage") = "" then CurPage = 1 'We're on the first page Else CurPage = Request.QueryString("CurPage") End If Dim connection %> <% 'Explicitly Create a recordset object Dim rs Set rs = Server.CreateObject("ADODB.Recordset") 'Set the cursor location property rs.CursorLocation = adUseClient 'Set the cache size = to the # of records/page rs.CacheSize = NumPerPage 'Open our recordset ' Dim strSQL ' strSQL = "SELECT * FROM comments ORDER BY datum desc" rs.Open strSQL, Connection ' här har jag ändrat ! If Rs.eof Then response.redirect "comments.asp?Errorkod=nada" rs.MoveFirst rs.PageSize = NumPerPage 'Get the max number of pages Dim TotalPages TotalPages = rs.PageCount 'Set the absolute page rs.AbsolutePage = CurPage 'Counting variable for our recordset Dim count %>
 
(det går att söka på rubrik och text i matchkommentarerna)
<%if what = "search" then %> <% Else end if IF boks <> "" then%> <% end if IF Errorkod <> "" then Response.write "Din sökning gav inget resultat försök igen" end if %>
<% 'Set Count equal to zero Count = 0 Do While Not rs.EOF And Count < rs.PageSize %> <% Count = Count + 1 rs.MoveNext Loop %>
Listar 10 per sida, sorterat efter datum. Använd med fördel sökfunktionen att söka efter rubrik, lag och ord i text

   
 
<% If RS ("bild") = "" then 'inte mycket ! Else%> " border="0" align="right"> <%End if%> <%=rs ("Rubrik")%>

<%=rs ("Text")%>

Lag:<%=rs ("lag")%>
Inlagt:<%=rs ("datum")%>

 
     <% 'Print out the current page # / total pages Response.Write("Sida " & CurPage & " av " & TotalPages & "") %>
<% if curpage <> 1 then Response.Write("Föregående ") end if 'Display Next / Prev buttons if CurPage > 1 then 'We are not at the beginning, show the prev button Response.Write("Föregående ") End If %>   <% if CInt(CurPage) <> CInt(TotalPages) then 'We are not at the end, show a next button Response.Write(" Nästa ") Response.Write("Nästa") End If %>