Selam Forumu Biraz İnceledimde Bu konuda sıkıntısı olan çok asp için mysql arama ve mysql sayfalama kodları paylaşayım istedim inş. işinize yarar Kolay Gelsin
Mysqlde arama yapmak için Conn. adında db bağlantısını yaptığınızı varsayarak
<%
aranan=request.form("aranan")
KayitSayisi = 10
If Request.QueryString("s") <> "" Then
Sayfa = CInt(Request.QueryString("s"))
Elseif Request.QueryString("s") = "" then
Sayfa = 1
else
Sayfa = 1
End If
Set bakilan = conn.Execute("select * from fikra where baslik like '%" & aranan & "%' Or fikra like '%" & aranan & "%' ORDER BY id DESC LIMIT " & (KayitSayisi*Sayfa)-(KayitSayisi) & "," & KayitSayisi)
Set SQLTop = conn.Execute("select count(baslik) from fikra where baslik like '%" & aranan & "%' Or fikra like '%" & aranan & "%'")
TopKayit = SQLTop(0)
if bakilan.eof or bof then
%>
<%end if
if bakilan.eof then%>
Kayıt Bulunamadı
<%else%>
<table border="0" width="100%" id="table1">
<%
i=1
Do While Not bakilan.EOF
%> <%if i>1 then%><tr>
<td colspan="2"><hr></td>
</tr>
<%end if%>
<%
subject=bakilan("baslik")
data=bakilan("fikra")
subject=lcase(subject)
data=lcase(data)
data=left(data,80)
aranan=lcase(aranan)
subject=replace(subject,aranan,"<span style=""background-color: #FFFF00"">"&aranan&"</span>")
data=replace(data,aranan,"<span style=""background-color: #FFFF00"">"&aranan&"</span>")
%>
<tr>
<td width="5%" bgcolor="#EEEEEE"><%=i%></td>
<td width="93%" bgcolor="#EEEEEE"><a href="#fikraoku" onClick="MM_openBrWindow('fikra.asp?islem=oku&id=<%=bakilan("id")%>','','scrollbars=yes,width=500,height=400')"> <%=subject%></td></tr><tr><td>
<td colspan="2"><a href="#fikraoku" onClick="MM_openBrWindow('fikra.asp?islem=oku&id=<%=bakilan("id")%>','','scrollbars=yes,width=500,height=400')"><%=data%></td>
</tr><%i=i+1
bakilan.MoveNext
Loop
%>
</table>
<center>Sayfalar: <%if sayfa<>1 then
response.write "<a href=?s=1 title='İlk sayfaya git'><font size=2 face=webdings>7</font></a></a> "
end if
If sayfa > 1 Then
response.write "<a href='?s=" & sayfa - 1 & "' title='Bir önceki sayfaya git'><font size=2 face=webdings>3</font></a> "
End If
pagecount=cint(Topkayit/Kayitsayisi)+1
limit=5
For y=1 To PageCount
If sayfa=y Then
response.write "<font size=1><b>[" & y & "]</b></font>" & " "
Else
If sayfa-limit < y and y < sayfa+limit Then
response.write "<font size=1><a href=?s=" & y & ">[" & y & "]</a></font> "
End If
End If
Next
If sayfa < PageCount Then
response.write "<a href='?s=" & sayfa + 1 & "' title='Bir sonraki sayfaya git'><font size=2 face=webdings>4</font></a> "
End If
If sayfa <> PageCount Then
response.write "<a href='?s=" & PageCount & "' title='Son sayfaya git'><font size=2 face=webdings>8</font></a> "
End If
end if
%>
Mysqlde arama yapmak için Conn. adında db bağlantısını yaptığınızı varsayarak
<%
aranan=request.form("aranan")
KayitSayisi = 10
If Request.QueryString("s") <> "" Then
Sayfa = CInt(Request.QueryString("s"))
Elseif Request.QueryString("s") = "" then
Sayfa = 1
else
Sayfa = 1
End If
Set bakilan = conn.Execute("select * from fikra where baslik like '%" & aranan & "%' Or fikra like '%" & aranan & "%' ORDER BY id DESC LIMIT " & (KayitSayisi*Sayfa)-(KayitSayisi) & "," & KayitSayisi)
Set SQLTop = conn.Execute("select count(baslik) from fikra where baslik like '%" & aranan & "%' Or fikra like '%" & aranan & "%'")
TopKayit = SQLTop(0)
if bakilan.eof or bof then
%>
<%end if
if bakilan.eof then%>
Kayıt Bulunamadı
<%else%>
<table border="0" width="100%" id="table1">
<%
i=1
Do While Not bakilan.EOF
%> <%if i>1 then%><tr>
<td colspan="2"><hr></td>
</tr>
<%end if%>
<%
subject=bakilan("baslik")
data=bakilan("fikra")
subject=lcase(subject)
data=lcase(data)
data=left(data,80)
aranan=lcase(aranan)
subject=replace(subject,aranan,"<span style=""background-color: #FFFF00"">"&aranan&"</span>")
data=replace(data,aranan,"<span style=""background-color: #FFFF00"">"&aranan&"</span>")
%>
<tr>
<td width="5%" bgcolor="#EEEEEE"><%=i%></td>
<td width="93%" bgcolor="#EEEEEE"><a href="#fikraoku" onClick="MM_openBrWindow('fikra.asp?islem=oku&id=<%=bakilan("id")%>','','scrollbars=yes,width=500,height=400')"> <%=subject%></td></tr><tr><td>
<td colspan="2"><a href="#fikraoku" onClick="MM_openBrWindow('fikra.asp?islem=oku&id=<%=bakilan("id")%>','','scrollbars=yes,width=500,height=400')"><%=data%></td>
</tr><%i=i+1
bakilan.MoveNext
Loop
%>
</table>
<center>Sayfalar: <%if sayfa<>1 then
response.write "<a href=?s=1 title='İlk sayfaya git'><font size=2 face=webdings>7</font></a></a> "
end if
If sayfa > 1 Then
response.write "<a href='?s=" & sayfa - 1 & "' title='Bir önceki sayfaya git'><font size=2 face=webdings>3</font></a> "
End If
pagecount=cint(Topkayit/Kayitsayisi)+1
limit=5
For y=1 To PageCount
If sayfa=y Then
response.write "<font size=1><b>[" & y & "]</b></font>" & " "
Else
If sayfa-limit < y and y < sayfa+limit Then
response.write "<font size=1><a href=?s=" & y & ">[" & y & "]</a></font> "
End If
End If
Next
If sayfa < PageCount Then
response.write "<a href='?s=" & sayfa + 1 & "' title='Bir sonraki sayfaya git'><font size=2 face=webdings>4</font></a> "
End If
If sayfa <> PageCount Then
response.write "<a href='?s=" & PageCount & "' title='Son sayfaya git'><font size=2 face=webdings>8</font></a> "
End If
end if
%>