<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1011953" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1011953</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/highlighting-search-results#comment-1069123</link>
    <description> &lt;p&gt;It sounds like you have the same two problems that I always run into. &lt;/p&gt;
&lt;p&gt;1) A compelling need to overcomplicate what should be really simple. I wish I had a dollar for every time that I wrote some huge script to accomplish something only to find a 2-line solution a day later &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;2) The &quot;write for 5, debug for 25&quot; method. Maybe if we took 10 minutes to write in the first place we&#039;d be a lot better off in the long run.&lt;/p&gt;
 </description>
     <pubDate>Tue, 08 Aug 2000 17:25:59 +0000</pubDate>
 <dc:creator>Maverick</dc:creator>
 <guid isPermaLink="false">comment 1069123 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Got it!</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/highlighting-search-results#comment-1069069</link>
    <description> &lt;p&gt;Well, that was definitely too easy...!&lt;/p&gt;
&lt;p&gt;Psuedocode:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;nbsp; for each in the list of search word(s)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start at beginning of text&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; search for next match&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; copy all the text up to that match&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; add the highlight tag(s), copy the matched searchword, and the end highlight tag&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop to continue the search in the text&lt;br /&gt;next search word&lt;br /&gt;return results&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;Since I wanted to retain the existing case sensitivity after the highlighting, I couldn&#039;t just use a simple Replace function.  But it only took 30 minutes or so to get this working (5 to write, 25 to debug &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/tongue.png&quot; title=&quot;Sticking out tongue&quot; alt=&quot;Sticking out tongue&quot; class=&quot;smiley-content&quot; /&gt;).&lt;/p&gt;
&lt;p&gt;In the unlikely case that anyone cares, my actual source code for this is in the file &lt;a href=&quot;http://www.rewardslookup.com/include/SearchFuncs.inc&quot; class=&quot;bb-url&quot;&gt;http://www.rewardslookup.com/include/SearchFuncs.inc&lt;/a&gt;, and Highlight() is the second function in the file.  Go to &lt;a href=&quot;http://www.RewardsLookup.com/EarnSearch.asp?search=game+toy&amp;amp;srchtype=ANY&quot; class=&quot;bb-url&quot;&gt;http://www.RewardsLookup.com/EarnSearch.asp?search=game+toy&amp;amp;srchtype=ANY&lt;/a&gt; to see the game and toy words show up in green underline.&lt;/p&gt;
&lt;p&gt;Thanks again, Maverick.  Obvious though it may be, it wasn&#039;t until you suggested the search &amp;amp; replace methodology that I realized how easy this could be...!&lt;/p&gt;
&lt;p&gt;[Edited by KLWong on 08-07-2000 at 05:28 PM]&lt;/p&gt;
 </description>
     <pubDate>Mon, 07 Aug 2000 21:22:27 +0000</pubDate>
 <dc:creator>KLWong</dc:creator>
 <guid isPermaLink="false">comment 1069069 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/highlighting-search-results#comment-1068862</link>
    <description> &lt;p&gt;Thanks for your very helpful reply.  I don&#039;t have my ASP books at work, but I &lt;strong&gt;think&lt;/strong&gt; there&#039;s a VB search &amp;amp; replace type of function that I can use.  If not, I&#039;ll follow the example of your code to write my own.  Why I didn&#039;t think of this relatively obvious scheme before, I have no idea...&lt;/p&gt;
&lt;p&gt;(As long as I want to have the option of working on my site from work -- like during lunch, after hours, etc. -- I&#039;m stuck with an NT/ASP/Access database implementation, because I&#039;m not allowed to load any &quot;non-authorized&quot; applications onto my work PC.)&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;br /&gt;
Kristen&lt;/p&gt;
 </description>
     <pubDate>Fri, 04 Aug 2000 14:23:58 +0000</pubDate>
 <dc:creator>KLWong</dc:creator>
 <guid isPermaLink="false">comment 1068862 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/highlighting-search-results#comment-1068837</link>
    <description> &lt;p&gt;Well, if you&#039;d like to abandon ASP and move to a Unix server, I could tell you how to do it in PHP &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I&#039;m not sure what the coding is for ASP, but the principle should be the same. You&#039;ve already got the search string stored as some variable since that&#039;s what you&#039;re using to query the database. After you&#039;ve done the query and gotten the result, do a string replace on the result and replace the search string with the string plus tags to highlight it.&lt;/p&gt;
&lt;p&gt;So if your the word searched for was in a variable named $searchstring and the query results were in $result&lt;/p&gt;
&lt;p&gt;In PHP it would be something like:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;$result = str_replace (&amp;quot;$searchstring&amp;quot;, &amp;quot;&amp;lt;B&amp;gt;$searchstring&amp;lt;/B&amp;gt;&amp;quot;, $result);&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;Then you plug that into the table that displays the results. If they searched for the word computer and the db query returned &quot;this is a page about computers&quot; the result would look like:&lt;br /&gt;
This is a page about &lt;strong&gt;computer&lt;/strong&gt;s&lt;/p&gt;
&lt;p&gt;I&#039;m sure that would work in PHP, in ASP try this:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;// instr:&amp;nbsp; string to search in.&lt;br /&gt;// oldstr: string to search for, ignoring the case.&lt;br /&gt;// newstr: string replacing the occurences of oldstr.&lt;br /&gt;CString ReplaceNoCase( LPCTSTR instr, LPCTSTR oldstr, LPCTSTR newstr )&lt;br /&gt;{&lt;br /&gt;	CString output( instr );&lt;br /&gt;&lt;br /&gt;	// lowercase-versions to search in.&lt;br /&gt;	CString input_lower( instr );&lt;br /&gt;	CString oldone_lower( oldstr );&lt;br /&gt;	input_lower.MakeLower();&lt;br /&gt;	oldone_lower.MakeLower();&lt;br /&gt;&lt;br /&gt;	// search in the lowercase versions,&lt;br /&gt;	// replace in the original-case version.&lt;br /&gt;	int pos=0;&lt;br /&gt;	while ( (pos=input_lower.Find(oldone_lower,pos))!=-1 ) {&lt;br /&gt;&lt;br /&gt;		// need for empty &amp;quot;newstr&amp;quot; cases.&lt;br /&gt;		input_lower.Delete( pos, lstrlen(oldstr) );	&lt;br /&gt;		input_lower.Insert( pos, newstr );&lt;br /&gt;&lt;br /&gt;		// actually replace.&lt;br /&gt;		output.Delete( pos, lstrlen(oldstr) );&lt;br /&gt;		output.Insert( pos, newstr );&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	return output;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;No guarantees that it&#039;ll work though &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;[Edited by Maverick on 08-03-2000 at 11:00 PM]&lt;/p&gt;
 </description>
     <pubDate>Fri, 04 Aug 2000 02:53:04 +0000</pubDate>
 <dc:creator>Maverick</dc:creator>
 <guid isPermaLink="false">comment 1068837 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
