Avatar billede loukas Mester
12. marts 2003 - 22:20 Der er 17 kommentarer og
1 løsning

loop .movenext ??

Hvad gør jeg forkert.
Hvis posten findes i arrayet skal den ikke skrives, men gå videre til næste i Recordsettet!!!

If Not (rs2.BOF Or rs2.EOF) Then

                       
            Do While Not rs2.EOF or rs2.BOF
           
                strID = rs2("id")
                arrID = split(arrID1,",")
           
                For t = 0 to Ubound(arrID)
                       
                        if Cstr(arrId(t)) = Cstr(strID) then'*********
                           
                            Response.Write "------------------<br>"
                                        rs2.movenext
                                       
                           
                        else'*********
                                strTitel = " "
                                if len(rs2("titel")) < 1 then
                                    strTitel = rs2("www")
                                    strTitel = Replace(strTitel,"http://www.","")
                                else
                                    strTitel = rs2("titel")
                                end if
               
                                    Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                                    Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                                    Response.Write "</td></tr></table>"
                                                rs2.movenext
                                               
                        end if'*********
                Next
                loop   
           
           
Else
                Response.Write ""
End If
       
            Set rs2 = Nothing
Avatar billede sth Novice
12. marts 2003 - 22:25 #1
du skallige have en MoveNext inden din loop

rs2.MoveNext
LOOP
Avatar billede medions Nybegynder
12. marts 2003 - 22:25 #2
If Not rs2.EOF Then
    While Not rs2.EOF
               
        strID = rs2("id")
        arrID = split(arrID1,",")
               
        For t = 0 to Ubound(arrID)
            if Cstr(arrId(t)) = Cstr(strID) then'*********
                                   
                Response.Write "------------------<br>"                           
            else'*********
                    strTitel = " "
                    if len(rs2("titel")) < 1 then
                        strTitel = rs2("www")
                        strTitel = Replace(strTitel,"http://www.","")
                    else
                        strTitel = rs2("titel")
                    end if
                       
                        Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                        Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                        Response.Write "</td></tr></table>"                                                       
            end if'*********
        rs2.movenext
    Wend
Else
                Response.Write ""
End If
       
Set rs2 = Nothing

//>Rune
Avatar billede sth Novice
12. marts 2003 - 22:27 #3
altså noget i denne stil:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
If Not (rs2.BOF Or rs2.EOF) Then

                       
            Do While Not rs2.EOF or rs2.BOF
           
                strID = rs2("id")
                arrID = split(arrID1,",")
           
                For t = 0 to Ubound(arrID)
                       
                        if Cstr(arrId(t)) = Cstr(strID) then'*********
                           
                            Response.Write "------------------<br>"
                                       
                                       
                           
                        else'*********
                                strTitel = " "
                                if len(rs2("titel")) < 1 then
                                    strTitel = rs2("www")
                                    strTitel = Replace(strTitel,"http://www.","")
                                else
                                    strTitel = rs2("titel")
                                end if
               
                                    Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                                    Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                                    Response.Write "</td></tr></table>"
                                           
                                               
                        end if'*********
                rs2.movenext
                loop   
           
           
Else
                Response.Write ""
End If
       
            Set rs2 = Nothing
</BODY>
</HTML>
Avatar billede loukas Mester
12. marts 2003 - 22:34 #4
På Runes forslag får jeg fejlen:
Fejltype:
Der opstod en Microsoft VBScript-kompileringsfejl (0x800A0400)
En sætning var ventet
search.asp, line 124

og der er lige efter wend
Avatar billede medions Nybegynder
12. marts 2003 - 22:37 #5
Sorry.. manglede et Next!

If Not rs2.EOF Then
    While Not rs2.EOF
               
        strID = rs2("id")
        arrID = split(arrID1,",")
               
        For t = 0 to Ubound(arrID)
            if Cstr(arrId(t)) = Cstr(strID) then'*********
                                   
                Response.Write "------------------<br>"                           
            else'*********
                    strTitel = " "
                    if len(rs2("titel")) < 1 then
                        strTitel = rs2("www")
                        strTitel = Replace(strTitel,"http://www.","")
                    else
                        strTitel = rs2("titel")
                    end if
                       
                        Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                        Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                        Response.Write "</td></tr></table>"                                                       
            end if'*********
        Next
       
        rs2.movenext
    Wend
Else
                Response.Write ""
End If
       
Set rs2 = Nothing

//>Rune
Avatar billede loukas Mester
12. marts 2003 - 22:44 #6
ok, nu skriver den ud, men :-(
Jeg poster lige hele koden så kan du se hvad det er jeg vil.
Og nej jeg tror ikke det kan laves i sql'en
det er mySQL3.23

den skriver samme post flere gange i anden søgning ??


            strSQL =  "select * from power where Ucase(www) like '%" & strKeyword(0) & "%' and Ucase(titel) like '%" & strKeyword(0) & "%' and Ucase(description) like '%" & strKeyword(0) & "%' and Ucase(html) like '%" & strKeyword(0) & "%';"
       
            Set rs = Conn.Execute(strSQL)
           
If Not (rs.BOF Or rs.EOF) Then
           
           
            Do While Not rs.EOF
            Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
            Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" >" & "<a href="& rs("www")&" TARGET=_blank>"& rs("titel") &"</A> - " & rs("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
            Response.Write "</td></tr></table>"
           
            arrId1 = arrId1 + Cstr(rs("id")) & ", "
           
            rs.MoveNext
            Loop
Else
            Response.Write "<br>"
End If
           
            Set rs = nothing
            Response.Write "<BR><BR><BR><BR><BR>"
            Response.Flush

           
           
           
           
           
           
           
'----------------- DOMÆNE & TITLE & DESCRIPTION ------------------------------------------
            strSQL2 =  "select * from power where www like '%"&strKeyword(0)&"%' and titel like '%"&strKeyword(0)&"%' and description like '%"&strKeyword(0)&"%';"
            Set rs2 = Conn.Execute(strSQL2)

If Not rs2.EOF Then
    While Not rs2.EOF
               
        strID = rs2("id")
        arrID = split(arrID1,",")
               
        For t = 0 to Ubound(arrID)
            if Cstr(arrId(t)) = Cstr(strID) then'*********
                                   
                Response.Write "------------------<br>"                           
            else'*********
                    strTitel = " "
                    if len(rs2("titel")) < 1 then
                        strTitel = rs2("www")
                        strTitel = Replace(strTitel,"http://www.","")
                    else
                        strTitel = rs2("titel")
                    end if
                       
                        Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                        Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                        Response.Write "</td></tr></table>"                                                       
            end if'*********
        Next
       
        rs2.movenext
    Wend
Else
                Response.Write ""
End If
       
Set rs2 = Nothing
Avatar billede medions Nybegynder
12. marts 2003 - 22:49 #7
strSQL =  "select * from power where Ucase(www) like '%" & strKeyword(0) & "%' and Ucase(titel) like '%" & strKeyword(0) & "%' and Ucase(description) like '%" & strKeyword(0) & "%' and Ucase(html) like '%" & strKeyword(0) & "%';"
       
            Set rs = Conn.Execute(strSQL)
           
If Not (rs.BOF Or rs.EOF) Then
           
           
            Do While Not rs.EOF
            Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
            Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" >" & "<a href="& rs("www")&" TARGET=_blank>"& rs("titel") &"</A> - " & rs("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
            Response.Write "</td></tr></table>"
           
            arrId1 = arrId1 + Cstr(rs("id")) & ", "
           
            rs.MoveNext
            Loop
Else
            Response.Write "<br>"
End If
           
            Set rs = nothing
            Response.Write "<BR><BR><BR><BR><BR>"
            Response.Flush

           
           
           
           
           
           
           
'----------------- DOMÆNE & TITLE & DESCRIPTION ------------------------------------------
            strSQL2 =  "select DISTINCT titel, www, description, id from power where www like '%"&strKeyword(0)&"%' and titel like '%"&strKeyword(0)&"%' and description like '%"&strKeyword(0)&"%';"
            Set rs2 = Conn.Execute(strSQL2)

If Not rs2.EOF Then
    While Not rs2.EOF
               
        strID = rs2("id")
        arrID = split(arrID1,",")
               
        For t = 0 to Ubound(arrID)
            if Cstr(arrId(t)) = Cstr(strID) then'*********
                                   
                Response.Write "------------------<br>"                           
            else'*********
                    strTitel = " "
                    if len(rs2("titel")) < 1 then
                        strTitel = rs2("www")
                        strTitel = Replace(strTitel,"http://www.","")
                    else
                        strTitel = rs2("titel")
                    end if
                       
                        Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                        Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                        Response.Write "</td></tr></table>"                                                       
            end if'*********
        Next
       
        rs2.movenext
    Wend
Else
                Response.Write ""
End If
       
Set rs2 = Nothing

//>Rune
Avatar billede loukas Mester
12. marts 2003 - 22:55 #8
øv, den vil ikke
du kan prøve ar søge på aarhus her:
http://80.197.72.253/mySQL/search/search.asp?Keyword=aarhus
Avatar billede medions Nybegynder
12. marts 2003 - 22:59 #9
Hvordan ser det ud hvis du gør sådan her?
          strSQL =  "select * from power where Ucase(www) like '%" & strKeyword(0) & "%' and Ucase(titel) like '%" & strKeyword(0) & "%' and Ucase(description) like '%" & strKeyword(0) & "%' and Ucase(html) like '%" & strKeyword(0) & "%';"
       
            Set rs = Conn.Execute(strSQL)
           
If Not (rs.BOF Or rs.EOF) Then
           
           
            Do While Not rs.EOF
            Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
            Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" >" & "<a href="& rs("www")&" TARGET=_blank>"& rs("titel") &"</A> - " & rs("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
            Response.Write "</td></tr></table>"
           
            arrId1 = arrId1 + Cstr(rs("id")) & ", "
           
            rs.MoveNext
            Loop
Else
            Response.Write "<br>"
End If
           
            Set rs = nothing
            Response.Write "<BR><BR><BR><BR><BR>"
            Response.Flush

           
           
           
           
           
           
           
'----------------- DOMÆNE & TITLE & DESCRIPTION ------------------------------------------
            strSQL2 =  "select DISTINCT titel, www, description, id from power where www like '%"&strKeyword(0)&"%' and titel like '%"&strKeyword(0)&"%' and description like '%"&strKeyword(0)&"%';"
            Set rs2 = Conn.Execute(strSQL2)

If Not rs2.EOF Then
    While Not rs2.EOF
               
            if Cstr(arrId(t)) = Cstr(strID) then'*********
                                   
                Response.Write "------------------<br>"                           
            else'*********
                    strTitel = " "
                    if len(rs2("titel")) < 1 then
                        strTitel = rs2("www")
                        strTitel = Replace(strTitel,"http://www.","")
                    else
                        strTitel = rs2("titel")
                    end if
                       
                        Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                        Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                        Response.Write "</td></tr></table>"                                                       
            end if'*********
       
        rs2.movenext
    Wend
Else
                Response.Write ""
End If
       
Set rs2 = Nothing

//>Rune
Avatar billede loukas Mester
12. marts 2003 - 23:04 #10
Der opstod en Microsoft VBScript-kørselsfejl fejl '800a000d'

Typer stemmer ikke overens

/mySQL/search/search.asp, linje 101

If Not rs2.EOF Then
    While Not rs2.EOF
               
            if Cstr(arrId(t)) = Cstr(strID) then'<--- linje 101 ---
Avatar billede loukas Mester
12. marts 2003 - 23:07 #11
Der skal vel en split(arrId1) til ??
Avatar billede loukas Mester
12. marts 2003 - 23:11 #12
Nu ser den sådan her ud, men den skriver de samme poster, som fra første søgning ?

strSQL =  "select * from power where Ucase(www) like '%" & strKeyword(0) & "%' and Ucase(titel) like '%" & strKeyword(0) & "%' and Ucase(description) like '%" & strKeyword(0) & "%' and Ucase(html) like '%" & strKeyword(0) & "%';"
       
            Set rs = Conn.Execute(strSQL)
           
If Not (rs.BOF Or rs.EOF) Then
           
           
            Do While Not rs.EOF
            Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
            Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" >" & "<a href="& rs("www")&" TARGET=_blank>"& rs("titel") &"</A> - " & rs("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
            Response.Write "</td></tr></table>"
           
            arrId1 = arrId1 + Cstr(rs("id")) & ", "
           
            rs.MoveNext
            Loop
Else
            Response.Write "<br>"
End If
           
            Set rs = nothing
            Response.Write "<BR><BR><BR><BR><BR>"
            Response.Flush

            arrID = split(arrID1)
           
           
           
           
           
           
'----------------- DOMÆNE & TITLE & DESCRIPTION ------------------------------------------
            strSQL2 =  "select DISTINCT titel, www, description, id from power where www like '%"&strKeyword(0)&"%' and titel like '%"&strKeyword(0)&"%' and description like '%"&strKeyword(0)&"%';"
            Set rs2 = Conn.Execute(strSQL2)

If Not rs2.EOF Then
    While Not rs2.EOF
             
            if Cstr(arrId(t)) = Cstr(strID) then'*********
                                   
                Response.Write "------------------<br>"                           
            else'*********
                    strTitel = " "
                    if len(rs2("titel")) < 1 then
                        strTitel = rs2("www")
                        strTitel = Replace(strTitel,"http://www.","")
                    else
                        strTitel = rs2("titel")
                    end if
                       
                        Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
                        Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
                        Response.Write "</td></tr></table>"                                                       
            end if'*********
       
        rs2.movenext
    Wend
Else
                Response.Write ""
End If
       
Set rs2 = Nothing
Avatar billede medions Nybegynder
12. marts 2003 - 23:14 #13
<%
strSQL =  "select * from power where Ucase(www) like '%" & strKeyword(0) & "%' and Ucase(titel) like '%" & strKeyword(0) & "%' and Ucase(description) like '%" & strKeyword(0) & "%' and Ucase(html) like '%" & strKeyword(0) & "%';"
       
            Set rs = Conn.Execute(strSQL)
           
If Not (rs.BOF Or rs.EOF) Then
           
           
            Do While Not rs.EOF
            Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
            Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" >" & "<a href="& rs("www")&" TARGET=_blank>"& rs("titel") &"</A> - " & rs("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
            Response.Write "</td></tr></table>"
           
            arrId1 = arrId1 + Cstr(rs("id")) & ", "
           
            rs.MoveNext
            Loop
Else
            Response.Write "<br>"
End If
           
            Set rs = nothing
            Response.Write "<BR><BR><BR><BR><BR>"
            Response.Flush

            arrID = split(arrID1)
           
           
           
           
           
           
'----------------- DOMÆNE & TITLE & DESCRIPTION ------------------------------------------
            strSQL2 =  "select DISTINCT titel, www, description, id from power where www like '%"&strKeyword(0)&"%' and titel like '%"&strKeyword(0)&"%' and description like '%"&strKeyword(0)&"%';"
            Set rs2 = Conn.Execute(strSQL2)

If Not rs2.EOF Then
    While Not rs2.EOF
             
        strTitel = " "
        if len(rs2("titel")) < 1 then
            strTitel = rs2("www")
            strTitel = Replace(strTitel,"http://www.","")
        else
            strTitel = rs2("titel")
        end if
                       
            Response.Write "<table border=""0"" cellspacing=""0"" width=""760"" cellpadding=""3"" >"
            Response.Write "<tr><td width=99% ><FONT FACE=""Verdana, Times New Roman"" SIZE=""2"" color=""red"">" & "<a href="& rs2("www")&" TARGET=_blank>"& strTitel &"</A> - " & rs2("description")&"<BR></FONT><FONT FACE=""Verdana, Times New Roman"" SIZE=""1"" ></FONT><hr>"
            Response.Write "</td></tr></table>"                                                       
       
        rs2.movenext
    Wend
Else
                Response.Write ""
End If
       
Set rs2 = Nothing
%>

//>Rune
Avatar billede loukas Mester
12. marts 2003 - 23:19 #14
Jeg er ikke med, hvordan skal den undgå at skrive de samme resultater i begge søgninger ??
Avatar billede medions Nybegynder
12. marts 2003 - 23:24 #15
Jeg er altså  overhovedet ikke med på hvad det er du vil!
-Vil du ik' bare ha' en søgemaskine der udskriver det du søger på?

//>Rune
Avatar billede loukas Mester
12. marts 2003 - 23:28 #16
jo, men resultaterne skal sorteres.

1. Hvor DOMÆNE & TITLE & DESCRIPTION & HTML er = søgeordet
2. DOMÆNE & TITLE er = søgeordet

men i nummer 2. vil der komme nogle af de samme poster som fra nummer 1.  og de skal jo ikke skrives igen..;-)
Avatar billede loukas Mester
14. marts 2003 - 00:20 #17
hmmmm, jeg synes desværre ikke det gik så godt det her :-(
der har været en misforståelse.....
Lukker
Avatar billede loukas Mester
14. marts 2003 - 00:21 #18
Og opretter igen :-)
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