webForumDet fria alternativet

Kastar ut inlägget från tabellen

ASP

5 svar · 127 visningar · startad av Rinaldo

Medlem sedan mars 20014 214 inlägg
Frågan#1

Denna kod kastar ut inlägg från tabellen den ligger i när jag använder funktionen redigeraText.

Den gör bara detta i response.write och inte vanligt i början...

<!-- #INCLUDE FILE="adovbs.inc" -->
<!-- #INCLUDE FILE="connect.asp" -->
<HTML>
<HEAD>
<!-- #INCLUDE FILE="head.asp" -->
</HEAD>
<BODY >
<!-- #INCLUDE FILE="meny.asp" -->

<%SQL = "Select * From rubriker WHERE rubrikID = " & Request.QueryString("rubrikID") & " ORDER BY datum desc"
rs.open SQL, databas

Dim strText, iLength, iPos1, iPos2, iWordLength       	
Function redigeraText(strText) 			'funktion för att att redigera text mot HTML och radbrytningar och långa ord
	iPos1 = 1					
	iPos2 = 1
	iWordLength = 0
	strText = Trim(strText) 			
	Do Until iPos2 = Len(strText)			
		iPos2 = iPos2 + 1			
		iWordLength = iWordLength + 1 		
		If Mid(strText,iPos2,1) = " " Then
			iWordLength = 0
		End if
		If iWordLength > 60 Then		               			
			strText = Mid(strText,1,iPos1-1)_
			& Mid(strText,iPos1,iPos2-iPos1)_
			& " " & Mid(strText,iPos2,Len(strText)-iPos2+1)
			
			iPos1 = iPos2
			iPos2 = iPos2 + 1
			iWordLength = 0
		End If
	Loop
	strText = Replace(Server.HTMLEncode(strText), vbcrlf, "<br>" & vbcrlf)
	Response.Write strText 				
End Function

meddelande = rs("meddelande")
%>

<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="500" BGCOLOR="#999999"><TR><TD>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="500">
<TR>
<TD WIDTH="40" valign="top" bgcolor="#999999">
<IMG SRC="bilder/<%=rs("ikon")%>.gif">
</TD>
<TD WIDTH="600" bgcolor="#999999">
<b><%=(rs("rubrik"))%></b>
</TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="500">
<TR>
<TD WIDTH="170" valign="top" BGCOLOR="#CCCCCC"><BR>
<B>
<%response.write "<A HREF='visamedlem.asp?visamedlem=ja&medlem="&rs("namn")&"' CLASS=link>" & redigeraText(left(rs("namn"),20)) & "</A><BR>"%>
<%=rs("datum")%><BR><BR>
Antal svar: <%=rs("antalsvar")%></B>
</TD>
<TD WIDTH="470" BGCOLOR="#CCCCCC">
<%=redigeraText(meddelande)%>
</TD>
</TR>
</TABLE>
</TD></TR></TABLE><BR><BR>

<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="500" BGCOLOR="#999999"><TR><TD>Svar till inlägget </TD></TR><TR><TD>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="5" WIDTH="500">
<%
rs.close
mypage = Request("whichpage")
If mypage = "" then
   mypage = 1
End If
mypagesize = 10

SQL = "Select * From svar WHERE svartill = " & Request.QueryString("rubrikID") & " ORDER BY datum desc"

rs.cursorlocation = 3
rs.cachesize = 5

rs.open SQL,Databas
If rs.EOF then
   Response.write " </TD></TR></TABLE></TD></TR></TABLE><TABLE><TR><TD>Inga svar för tillfället</TD></TR></TABLE> " & sok
Else
   rs.movefirst
   rs.pagesize = mypagesize
   maxcount = Cint(rs.pagecount)
   rs.absolutepage = mypage
   howmanyrecs = 0
   howmanyfields = rs.fields.count -1
   Do While Not rs.EOF AND howmanyrecs < rs.pagesize
   counter = counter + 1
   If counter mod 2 = 0 then
      color = "#CCCCCC"
   Else
      color = "#EEEEEE"
   End If

   svar = rs("svar")
   Response.write "<TR BGCOLOR='" & color & "'><TD WIDTH=170 valign=top><img src=bilder/"&rs("ikon")&".gif ALIGN=left><B><A HREF='visamedlem.asp?visamedlem=ja&medlem="&rs("namn")&"' CLASS=link>" & left(rs("namn"),20) & "</A><BR>" & rs("datum") & "</B></TD>[b]<TD WIDTH=470>"& redigeraText(svar) &"</TD>[/b]</TR>"

   rs.movenext
   howmanyrecs = howmanyrecs + 1
   Loop
   rs.close
   Set rs = nothing

   response.write "</TABLE></TD></TR></TABLE><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH=500><TR><TD ALIGN=RIGHT>"
   If maxcount <> 0 then
   response.write "<B>sida " & mypage & " av " & maxcount & " </B>" & sidor:
   pad = "0"
   scriptname = request.Servervariables("script_name")
   for counter = 1 to maxcount
   If counter >= 40 then
      pad = ""
   End If
   ref = "&#0124; <a href='" & scriptname & "?rubrikID="& request.querystring("rubrikID")&"&whichpage=" & counter & "&pagesize=" & mypagesize & "' class=link>sida " & pad & counter & "</a> "
   response.write ref & " "
   if counter mod 40 = 0 then
      response.write ""
   End If
   Next
   End If
End If
%>

</TD></TR></TABLE>
</TD></TR></TABLE>

</BODY>
</HTML>
<%databas.close
set databas = nothing
%>

[Redigerat av Rinaldo den 03 okt 2001]

Medlem sedan dec. 200012 464 inlägg
#2
Function redigeraText(strText) 'funktion för att att redigera text mot HTML och radbrytningar och långa ord
iPos1 = 1 
iPos2 = 1
iWordLength = 0
strText = Trim(strText) 
Do Until iPos2 = Len(strText) 
iPos2 = iPos2 + 1 
iWordLength = iWordLength + 1 
If Mid(strText,iPos2,1) = " " Then
iWordLength = 0
End if
If iWordLength > 60 Then 
strText = Mid(strText,1,iPos1-1)_
& Mid(strText,iPos1,iPos2-iPos1)_
& " " & Mid(strText,iPos2,Len(strText)-iPos2+1)

iPos1 = iPos2
iPos2 = iPos2 + 1
iWordLength = 0
End If
Loop
strText = Replace(Server.HTMLEncode(strText), vbcrlf, "<br>" & vbcrlf)
[b]redigeraText = strText[/b] 
End Function

Använd inte globala variabler i funktionen utan lägg dom lokalt.

------------------
essentitia preter non sans multiplicandum

Medlem sedan mars 20014 214 inlägg
#3

Kanske byter ämne men finns det någon funktion som gör om http:// till länkar och kan man baka in det i denna?

Medlem sedan dec. 200012 464 inlägg
#4

http://script.webforum.nu/wf/Forum1/HTML/000093.html

------------------
essentitia preter non sans multiplicandum

Medlem sedan mars 20014 214 inlägg
#5

:oo

[Redigerat av Rinaldo den 04 okt 2001]

Medlem sedan mars 20014 214 inlägg
#6

har ingen någon bra http funktion man kan få låna

276 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
123 ms — deklarationer (db)
0 ms — hämta statistik (cache)
145 ms — hämta tråd, inlägg och bilagor (db)
127 ms — ändringar (db)