Arama Scripti İle İlgili Sorunum Var...
-
merhaba
ben bir arama scripti düzenliyorum ama bir noktada takıldım.
script yazı ile ve kategori ile arama yapmayı sağlıyor ve ben buna ek olarak şehir olarakta arama
yapmasını istiyorum.Script 2 asp dosyasından oluşuyor birincisi form kısmı ikinciside bulunan
sonuçları ekrana yansıtan kısım.Birinci asp dosyasındaki değişiklikleri yaptım ve hiçbir sorun yok
aşağıda 1. asp dosyasının kodlarını görebilirsiniz:
<html>
<head>
<meta http-equiv="Content-Language" content="tr">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Arama</title>
</head>
<body link="#000000" vlink="#000000" alink="#000000">
<form method="POST" action="kriter_islem.asp">
<table border="2" width="100%" cellspacing="0" bgcolor="#C0C0C0" bordercolor="#F0F0F0" height="79">
<tr>
<td width="5%" height="21"><input type="checkbox" name="yazi_onay" value="evet" checked></td>
<td width="17%" height="21"><b>YAZARAK ARA :</b></td>
<td width="78%" height="21"><input type="text" name="yazi" size="20"></td>
</tr>
<tr>
<td width="5%" height="21"><input type="checkbox" name="Kategori_onay" value="evet"></td>
<td width="17%" height="21"><b>KATEGORİLER:</b></td>
<td width="78%" height="21"><select size="1" name="kategori">
<% set acentalarDB=server.CreateObject ("ADODB.Connection")
acentalarDB.open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("kayit.mdb"))
set rs = acentalardb.execute("select * from " & "a_katename")
while not rs.EOF %>
<option value="<%=rs("kategori_id")%>" selected><%=rs("kategori_ismi")%>
<%rs.MoveNext
wend%>
</select></td>
</tr>
<tr>
<td width="5%" height="25">
<input type="checkbox" name="Country_onay" value="evet"></td>
<td width="17%" height="25"><b>Şehirler:</b></td>
<td width="78%" height="25"><select size="1" name="country">
<% set countryDB=server.CreateObject ("ADODB.Connection")
countryDB.open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("kayit.mdb"))
set rs = countrydb.execute("select * from " & "a_countryname")
while not rs.EOF %>
<option value="<%=rs("country_id")%>" selected><%=rs("country")%>
<%rs.MoveNext
wend%>
</select></td>
</tr>
<tr>
<td width="5%" height="25"> </td>
<td width="17%" height="25"><input type="submit" value="Ara" name="ara"></td>
<td width="78%" height="25"><input type="reset" value="Sil" name="sil"></td>
</tr>
</table>
</form>
</body>
</html>
---------------------------------------------------------------
2. asp dosyasındaki takıldığım kısım ise sanırım sqlText kısmı aşağıdada 2. asp dosyasını
bulabilirsiniz:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-9">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>[ İlkePC ] ARAbulucuDB V1.0</title>
</head>
<%
yazi_onay = request.form("yazi_onay")
yazi = cstr(request.form("yazi"))
yazi = uCase(yazi)
kategori_onay = request.form("kategori_onay")
kategori = request.form("kategori")
country_onay = request.form("country_onay")
country = request.form("country")
yazi_bul = ""
kategori_bul = ""
country_bul = ""
if yazi_onay = "evet" then
yazi_bul = "and (uCase(firma_adi) like "%"&yazi&"%""
yazi_bul = yazi_bul & " or uCase (konusu) like "%"&yazi&"%""
yazi_bul = yazi_bul & " or uCase (firma_adi) like "%"&yazi&"%""
yazi_bul = yazi_bul & " or uCase (telefon) like "%"_
& yazi & "%" or uCase (fax) like "%"&yazi&"%")"
end if
if kategori_onay = "evet" then
kategori_bul = " and a_kate.kategori_id = " & kategori
end if
if country_onay = "evet" then
country_bul = "and a_kate.country_id = " & country
end if
set acentalarDB=server.CreateObject ("ADODB.Connection")
acentalarDB.open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("kayit.mdb"))
sqlText = "select acenta.ace_id, acenta.firma_adi, acenta.konusu, acenta.kat, acenta.no, acenta.telefon, acenta.fax from acenta, a_kate where acenta.ace_id = a_kate.ace_id "& yazi_bul & kategori_bul
set rs = server.Createobject("ADODB.Recordset")
rs.open sqlText,acentalarDB,1,3
radet = rs.recordcount
deste = 10
%>
<body bgcolor="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">
<SCRIPT language=javascript src="fade.js"></SCRIPT>
<b>Arama Sonuçları;</b> <b><%=radet%></b> adet kayıt bulundu!.
<%if rs.eof then
Response.Write "<center>Böyle bir bilgi bulunamamıştır!</center>"
else %>
<TABLE BORDER=0 bgcolor=#C0C0C0 width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
<TR>
<TD bgcolor="#808080">
<b>
Firma Adı</b>
<TD bgcolor="#808080"><b>Konusu</b>
<TD bgcolor="#808080"><b>Kat/No</b>
<TD bgcolor="#808080"><b>Telefon</b>
<TD bgcolor="#808080"><b>Fax</b></TD>
</TR>
<%
if request("s")<>"" then
sayfa = cdbl(request("s"))
rs.move sayfa*deste
else
sayfa = 0
end if
for t=1 to deste
if rs.eof then exit for
%>
<%
if t mod 2 = 0 then
renk = "#f0f0f0"
else
renk = "#f4f4f4"
end if
%><TR bgcolor="<%=renk%>">
<TD><a href="../acentalar/<%=rs ("no")%>.asp" class="fade"><%=rs ("firma_adi")%></a>
<TD><%=rs ("konusu")%>
<TD><%=rs ("kat")%>/<%=rs ("no")%>
<TD><%=rs ("telefon")%>
<TD><%=rs ("fax")%></TD>
</TR>
<%rs.MoveNext
next
rs.close
set rs = Nothing
acentalarDB.Close
set acentalarDB = Nothing
%>
</TABLE>
Sayfa No :
<%
if radet/deste = int(radet/deste) then sayfaadet = radet/deste else sayfaadet = int(radet/deste) +1
for p=0 to sayfaadet-1
if sayfa = p then
%>
<b><%=p+1%></b>
<% else %>
<A href="kriter_islem.asp?s=<%=p%>"><%=p+1%></A>
<%end if
next
end if%>
<p><a href="default.asp">Geri dön</a></p>
</HTML>
-------------------------------------------------------------------------------------
burdaki sqlText kısmındaki şu kısım ( a_kate where acenta.ace_id = a_kate.ace_id "& yazi_bul & kategori_bul )
sanırım acenta id ile kategori id si uyuşanları ekrana yansıtıyor.Ben bunların arasına birde
şehir id si uyuşanları yansıtmasını istiyorum.Kafam çok karıştı walla düzgün anlatabildimmi bilmiyorum.
Ama yardımcı olursanız çok sevinirim. -
sqlText = "select acenta.ace_id, acenta.firma_adi, acenta.konusu, acenta.kat, acenta.no, acenta.telefon, acenta.fax from acenta, a_kate where acenta.ace_id in a_kate.ace_id and acenta.kat like '"& yazi_bul & "' or acenta.firma_adi like '" & kategori_bul "'"
olabilir ama emin deilim, database dosyani vermen gerekio hangi fieldin ne türde olduğunu bilmem gerekiyor. Bu arama bir ağaç mantığı ilemi yoksa linear bi aramamı anlamadim
Toplam Hit: 1902 Toplam Mesaj: 2