Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/03/2004, 23:04
Avatar de tork
tork
 
Fecha de Ingreso: noviembre-2003
Ubicación: Veracruz
Mensajes: 153
Antigüedad: 21 años, 6 meses
Puntos: 0
Exclamación problemas con buscador

El problema que tengo es que en mi bsucador, a la hora que le pongo una palabra y le clickeo en buscar, me aparece toda la base de datos, no solo la palabra que busque. LO que yo quiero es que busque la palabra que le mando, no que me ponga la base de datos con todos los registros. Este es el código de mi web:

<%
sSQL = "Select * From Tabla1 Where UCase(pal) like '%" & UCase(Request("palabra")) & "%'"

If Request.QueryString("pag")<>"" then
Session("pagina")=Request.QueryString("pag")
Else
Session("pagina")=1
End If


Const adCmdText = &H0001
Const adOpenStatic = 3

Set Conn = Server.CreateObject("ADODB.Connection")
Set Command = Server.CreateObject("ADODB.Command")
Set RS =Server.CreateObject("ADODB.RecordSet")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; " & "Dbq=" & Server.MapPath("base.mdb")
RS.Open sSQL,Conn,adopenstatic,adcmdtext

num_registros = 5

RS.PageSize=num_registros
RS.AbsolutePage=Session("pagina")
%>
<html> <head> <title>Búsqueda en bozz</title> <style type="text/css">
a.clase1{font-family:Arial;color:white;text-decoration:none;}
a.clase1:hover{font-family:Arial;color:white;text-decoration:underline;}
a.clase1:active{font-family:Arial;color:white;text-decoration:none;}
a.clase1:visited{font-family:Arial;color:white;}
a.clase2{font-family:Verdana;color:#ff6347;text-decoration:underline;}
a.clase2:hover{font-family:Verdana;color:#ff6347;text-decoration:none;}
a.clase2:active{font-family:Verdana;color:#ff6347;text-decoration:none;}
a.clase2:visited{font-family:Verdana;color:#ff6347;}
</style> </head> <body bgcolor="white"> <center><img src="laweb.gif"></center>
<form method="Post" action="buscar.asp">
<p align="center"><font face="Tahoma" size="2"><b>Búsqueda:&nbsp;&nbsp;</b></font> <input type="text" name="pal" size="30" value="<%Request("pal") %>">
<input type="submit" value="Búsqueda" name="boton1" class="boton"></form> <input name="mode" type="hidden" id="mode" value="allwords"><p>
<table border=0 cellpadding=0 cellspacing=0><tr><td width=1 bgcolor=#808080><img width=1 height=1 alt=""></td><td width=1 bgcolor=#ffffff><img width=1 height=1 alt=""></td></table>
<table align="center" width=40% border=0 cellpadding=1 cellspacing=0 bgcolor=#3366cc><tr><td bgcolor=#3366cc nowrap><table width=100% border=0 cellpadding=1 cellspacing=0 bgcolor=#3366cc><tr><td align="center" bgcolor=#3366cc nowrap>
<b><font color="white"><a class="clase1" href="buscar.html">La Web</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="clase1" href="img.html">Imágenes</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="clase1" href="dir.html">Directorio</a></b></font>
<br></tr></td></table></table></table>
<table border=0 cellpadding=0 cellspacing=0><tr><td width=1 bgcolor=#808080><img width=1 height=1 alt=""></td><td width=1 bgcolor=#ffffff><img width=1 height=1 alt=""></td></table>
<table width=100% border=0 cellpadding=1 cellspacing=0 bgcolor=#3366cc><tr><td bgcolor=#3366cc nowrap><table width=100% border=0 cellpadding=1 cellspacing=0 bgcolor=#3366cc><tr><td bgcolor=#3366cc nowrap>
<font size=-1 color="white">Resultados obtenidos con <strong><font size=+1><%=Request("pal")%></font></strong> en la web &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE="+1">Página <B><%=Session("pagina")%></B> de <B><%=RS.PageCount%></B></FONT></font> </center></tr></td></table></table></table><font color="white">
<table width=100% border=0 cellpadding=0 cellspacing=0><tr><td bgcolor=#efefef width=100%>
<font color=#efefef>
<%
'Contamos el numero de campos de la tabla
num_campos=RS.Fields.Count
For campo=0 to num_campos-1%>
<%
Next
registros_mostrados = 0
While (Not RS.eof And registros_mostrados < num_registros)
registros_mostrados = registros_mostrados +1
%>
<div align="left"><b><font size="4" color="black"><a href="<%=rs.Fields("url")%>"><%=rs.Fields("Nombre" )%></font><br></b></a>
<font size="4" color="black"><%=rs.Fields("Des")%></font><br><a href="<%=rs.Fields("url")%>"><font size="4" color="green"><%=rs.Fields("url")%><br></font></a> <br>
<%
RS.MoveNext
Wend
%><br><b>
<font color="black" size=3>
Página&nbsp;&nbsp;</font></b>
<%
i=0
While i<RS.PageCount
i=i+1
%>
<b>
<a class="clase2" href="buscar.asp?pag=<%=i%>&palabra=<%=Request("pa l")%>"><%=i%></a>&nbsp;&nbsp;&nbsp;&nbsp;</b></font>

<%
Wend
%>
<%
RS.Close
Conn.Close
%>&nbsp;&nbsp;
<font face="arial" size=3 color="red"><b>
<%
starttime = Timer()
Do While tt < 300000
tt = tt + 1
Loop
endtime = Timer()
Response.Write "La busqueda tardó " & endtime-starttime & " seg "
%> </font>
</td></b>
</tr>
</table>
</table> </center></div> <p><center><font size=-1 color="black">&copy;2004 <b>Bozz</b> - Buscador de páginas web</font></p></center>
<div id="layer1" style="position:absolute; left:630px; top:20px;"><h3><a href="buscar.html">La web</a><br><a href="dir.html">Directorio</a><br><a href="conoce.html">Conoce Bozz</a></div></h3>
<div id="layer2" style="position:absolute; left:10px; top:20px;"><img src="bozz.gif" widht=110 height=58></div>
<h6><div align="right">
<%
Set oConn = Server.CreateObject ("ADODB.Connection")
Set RS = Server.CreateObject ("ADODB.RecordSet")
oConn.Open "Driver={Microsoft Access Driver (*.mdb)}; " & "Dbq=" & Server.MapPath("base.mdb")
sql = "SELECT * FROM Tabla3"
RS.Open sql, oConn, 1,3
If RS.EOF then
oConn.Execute"INSERT INTO Tabla3 (hits) VALUES (1)"
Else
oConn.Execute"UPDATE Tabla3 SET hits="&(rs("hits")+1)&""
End IF
Response.Write "visitas"":<B> "&RS("hits")&"</B>"
RS.Close
oConn.Close
Set RS = nothing
Set oConn = nothing
%>

</body> </html>

Gracias de antemano