Zoque.Forum
Dirsek Teması:
Geri Dön Zoque.Forum » Webmaster Kaynaklari » Sunucu Tabanlı Programlama (Server Side) » ASP » asp ile search


Yanıt
 
LinkBack Seçenekler
Old 08.01.2003   #1 (permalink)
 
Murathan's Avatar
 
Üyelik Tarihi: 08.11.2002
Yer: ISTANBUL
Yaş: 29
Mesaj: 502
asp ile search


Bundan bir süre önce ASP ile yazılan bir site içi aramada aratılan kelimeleri altı çizili göstermesini istiyorum ama sağlıklı bir sonuç elde edemedim.Mesela var olan sayfalarda kelimeyi taramıyormu ne yapıyorsa sonuçta kimi sayfalar çıkmıyor.
Murathan şu an çevrimdışı  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl'e kaydet! http://reddit.com/submit?url=%url%&title=%title%Wong'e kaydet!Yahoo'ya kaydet!Google'a kaydet!MSN'e kaydet!Facebook'e kaydet!
Mesajdan alıntı yaparak yeni bir cevap ekleyin
Old 08.01.2003   #2 (permalink)
 
soul's Avatar
 
Üyelik Tarihi: 13.07.2000
Yer: LND
Mesaj: 4,284
site içi aramada mı sorun var yoksa Sonuçlarda kelimelerin altını çizili göstermede mi ?

Sorununu biraz daha anlaşılır bir şekilde açıklarsan sanırım yardımcı olabiliriz.
__________________
FERRUH.MAVİTUNA - İnanmıyorum, yeni site!
soul şu an çevrimdışı  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl'e kaydet! http://reddit.com/submit?url=%url%&title=%title%Wong'e kaydet!Yahoo'ya kaydet!Google'a kaydet!MSN'e kaydet!Facebook'e kaydet!
Mesajdan alıntı yaparak yeni bir cevap ekleyin
Old 08.01.2003   #3 (permalink)
 
Murathan's Avatar
 
Üyelik Tarihi: 08.11.2002
Yer: ISTANBUL
Yaş: 29
Mesaj: 502
Kelimelerin altını çizmiyor sayfada olduğu halde bu durumda aranan kelime sanki o sayfada yokmuş gibi
Murathan şu an çevrimdışı  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl'e kaydet! http://reddit.com/submit?url=%url%&title=%title%Wong'e kaydet!Yahoo'ya kaydet!Google'a kaydet!MSN'e kaydet!Facebook'e kaydet!
Mesajdan alıntı yaparak yeni bir cevap ekleyin
Old 08.01.2003   #4 (permalink)
 
soulburn's Avatar
 
Üyelik Tarihi: 29.11.2000
Yer: istanbul
Yaş: 28
Mesaj: 1,189
programmersresource.com/default.asp

burayı incelersen mantığı anlarsın..

Kod:
High-Lighting Key Words in Search Results 

By Jeremy Ramos 

A few things one should understand before attempting to understand this code. An understanding of the Basic string functions would help out a bit. 

This search uses a basic Access Database to query through. So lets begin the code. 

Here is the basic form to submit to your search page. 

<form method="post" action="/template.ASP"> 

Search our site and find the information you need! 
Use and, or, and the space to search for multiple words. 

<Input type="text" value="" name="keyword" size="30">
<input type="Submit" value="Search the site">
<Input type="hidden" value="yes" name="srch">
</form> 

This search will look for Boolean expressions like “and” and “or” as well as blanks like “visual basic”. 

Now for the ASP code to get the results from the search. 


<%
if request("srch") = "yes" then
  dim count,nWord,spWord,andWord,orWord
  ‘ set up variables

  
  word=replace(trim(request("keyword")),"'", "''")
  ‘ trim spaces and replace the single quote

  
  if instr(word,"and") then
    ‘ check Boolean of and
    
    andW = true
    Word = split(word,"and")
    ‘now get all the words separated by and into an array

    
    for i = 0 to ubound(andWord)
      if i <> ubound(andWord) then
        kW = "'%" & andWord(i) & "%'" 
        ‘set up SQL statement
        
      elseif i = ubound(andWord) then
        ‘ when it hits the end
        
        kW = kW &"'%" & andWord(i) & "%' and "
        ‘ add the last SQL statement
       
      end if
    next

  elseif instr(word,"or") then
    orW = true
    orWord = split(word,"or")
    for i = 0 to ubound(orWord)
      if i <> ubound(orWord) then
        kW = "'%" & orWord(i) & "%' and "
      elseif i = ubound(orWord) then
        kW = kW & "'%" & orWord(i) & "%'"
      end if
    next

  elseif instr(word," ") then
    spW = true
    spWord = split(word," ")
    for i = 0 to ubound(spWord)
      if i <> ubound(spWord) then
        kW = "'%" & spWord(i) & "%' or "
      elseif i = ubound(spWord) then
        kW = kW & "'%" & spWord(i) & "%'"
      end if
    next
  else
    
    ‘There is no Boolean value or Blank in the search word
    
    kW = "'%" & word & "%'"
  end if

  set conn = server.createobject("adodb.connection")
  conn.open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & _
  server.MapPath("\your.mdb"))

  set rs = server.createobject("adodb.recordset")
  SQL = "select * from content where pageBody like " & kW

  
Now you have your connection set and SQL built for the database search, 
all that’s left is to open the recordset and highlight.

  
  with rs
    .open
    SQL,conn,3,3

    if not .eof then
      do while not .eof
        pageBody = rs("pageBody")
        ‘ pass the field value to a local variable
        
        if andW then 
          ‘this is from above when we checked for a Boolean value of AND
          
          for i = 0 to ubound(andWord)
            ‘go through the search word array
            
            pos = instr(pageBody,andWord(i)) 
            ‘find the position of the word in the field.
            
            strW = trim(left(andWord(i),pos))
            ‘ now pass the word found to local variable.
            
            newStr = "<strong>" & strW & "</strong>"
            ‘ and highlight the found word with bold HTML tags.
            
            pageBody = replace(pageBody,strW,newStr)
            ‘ now put back the word into pageBody variable.
            If we didn’t pass the rs(“pageBody”) first it would overwrite 
            the variable every time it goes through the loop.
            
          Next
          
        ‘Now just set up two more for loops for “OR” and for BLANKS
        ‘The last one will be no Boolean values or blanks.
        
      else
        pos = instr(pageBody,word)
        strW = trim(left(word,pos))
        newStr = "<strong>" & strW & "</strong>"
        pageBody = replace(pageBody,strW,newStr)
      end if
      
      ‘Now write out the results from the query with the highlighted 
      words in there.
      
      response.write pageBody & "<hr><br>"
      .movenext
      loop
    else
      response.write "<br>No matching records<br>"
    end if
  end with
end if
%>
__________________
Since 2k - CG | U.K.
soulburn şu an çevrimdışı  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl'e kaydet! http://reddit.com/submit?url=%url%&title=%title%Wong'e kaydet!Yahoo'ya kaydet!Google'a kaydet!MSN'e kaydet!Facebook'e kaydet!
Mesajdan alıntı yaparak yeni bir cevap ekleyin
Old 08.01.2003   #5 (permalink)
 
soul's Avatar
 
Üyelik Tarihi: 13.07.2000
Yer: LND
Mesaj: 4,284
Şöyle yazdığım bir fonksiyon vardı. Kısa sade ve işine yarar herhalde.

alletxt = text arama sonucu
word = ise arama kelimen Request.Querystring("search") gibi

Eğer birden azla kelimeyi de "," virgül ile ayırıp verirsen hepsini Google gibi farklı renkler ile çiziyor.

Örn. Kullanımı :
Response.Write fm_hilite(strCode,"Kelime1,Kelime2,Kelime3")


Kod:
Function fm_hilite(byval alltext,byval word)
	Dim Arrword, i, ArrColorList(15), Color, xx
	Arrword = Split(word,",") '// Make an array from wordlist
	
	Dim ArrNewCList, ArrListi
	ArrNewCList = Array ("DF0","DFC","9F0","FCF","9FF","FF0","FF9")

	For i = 0 to Ubound(Arrword)
		word = Trim(Arrword(i))	
		If Instr(alltext,word) > 0 Then
			alltext = Replace(alltext,word,"<span style=""background-color:#" & ArrNewClist(ArrListi mod Ubound(ArrNewCList)) & "; font-weight:bold"">" & word & "</span>")
			ArrListi = ArrListi + 1
		End If
	Next

	fm_hilite = alltext
End Function
__________________
FERRUH.MAVİTUNA - İnanmıyorum, yeni site!
soul şu an çevrimdışı  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl'e kaydet! http://reddit.com/submit?url=%url%&title=%title%Wong'e kaydet!Yahoo'ya kaydet!Google'a kaydet!MSN'e kaydet!Facebook'e kaydet!
Mesajdan alıntı yaparak yeni bir cevap ekleyin
Old 08.01.2003   #6 (permalink)
 
Murathan's Avatar
 
Üyelik Tarihi: 08.11.2002
Yer: ISTANBUL
Yaş: 29
Mesaj: 502
Hocam çok sağol teşekkür ediyorum (bu gece) inceleyeceğim
Murathan şu an çevrimdışı  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl'e kaydet! http://reddit.com/submit?url=%url%&title=%title%Wong'e kaydet!Yahoo'ya kaydet!Google'a kaydet!MSN'e kaydet!Facebook'e kaydet!
Mesajdan alıntı yaparak yeni bir cevap ekleyin
Sponsorlu Bağlantılar
Zoque.Forum
Reklam
Yanıt

Etiketler

search , asp


 
Zoque'a hoşgeldiniz!
Zoque 27.02.1999 tarihinde yayın hayatına başlamış, paylaşıma dayalı bir oluşumdur. Tasarım, teknoloji, web, kültür ve sanat ana başlıkları altında bilgi paylaşımı ve benzer değerlere sahip katılımcıların birbirleriyle iletişime girmelerine imkan sağlar. "Az ama Öz" sloganından yola çıkarak, kaliteli ve nitelikli katılımı temel alır.

Saygın ve ciddi bir ortamda yardımlaşmak, haberleşmek, kendi bildiklerini diğer katılımcılarla paylaşmak isteyen, oluşumumuza düzenli katılımda bulunacağı inancını taşıyan konuklarımızı üye olmaya davet ediyoruz. [ » ]


Üye Girişi:

En popüler ilk 100 etiket
Tag Cloud
acil adsl ajax almak arama araniyor ariyorum ariyoruz asp bilen bilgi bilgisayar blog calisma css div domain dosya eleman film firefox flash font form forum fotograf freelance google gore grafik grafiker hakkinda hangi hata hatasi hosting html ilgili ilk image internet istanbul istiyorum java javascript karakter kayit kisisel kullanimi link logo mac mail menu microsoft muzik mysql nasil neden nedir online oyun photoshop php problemi program programi reklam resim satilik sayfa script server ses sistemi site sitesi son soru sorun sorunsali sorunu sql swf tasarim tasarimci tasarimcisi tasarimi turk turkce veri video web windows wordpress xml yardim yazi yeni zoque
Zoque RSS Aboneliği
Son eklenen konuları e-posta ile haber verelim mi?

Forum Yazılımı: vBulletin® Version 3.7.4 Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

Arayüz/Skin "Güneş" © www.zoque.com / net. Copyright © 1999 - 2008
Forum Saati GMT +2. Şu anda saat: 08:07.