Results Highlighting

Post Reply
source1Tamer
Posts: 91
Joined: Tue Nov 13, 2001 3:49 pm

Results Highlighting

Post by source1Tamer »

I'm trying to highlight the results returned from the SQL query, following is a snippet of my code:

<!---------------------------------------------------->
<fmtcp query "%mbH" $srchQuery>
<SQL ROW SKIP=$jump MAX=$recsperpage "select URL from sites">
<mm>$URL</mm>
<!---------------------------------------------------->

The variable $URL is only highlighted in the first loop, after that it's not....I don't know why
any clues??

Tamer
Source1Solutions
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

Results Highlighting

Post by Kai »

What is your $srchQuery? What are some later values of $URL that are not being highlighted?
source1Tamer
Posts: 91
Joined: Tue Nov 13, 2001 3:49 pm

Results Highlighting

Post by source1Tamer »

$srchQuery is the word that I'm looking for.
so let's say I'm looking for the word 'Auto',in a database field called URL, I'll do the following:
<!---------------------------------------------------->
<$srchQuery = 'Auto'>
<fmtcp query "%mbH" $srchQuery>
<SQL ROW SKIP=$jump MAX=$recsperpage "select URL from sites">
<mm>$URL</mm>
<!---------------------------------------------------->

I got the results as:
www.auto-clubs.net
www.autobuzz.com
www.autoclinic.net
www.automags.org
www.autometrix.co.uk

Only the word 'auto' in the first record was bold.
The wierd thing is when I try to search using a different word like 'help' I'm getting the bold highlight in a randum manner, for instance, the records 1,4,5 are bold but 2,3,6,7 are not !

I tried not to use the fmtcp function and instead, I've used the <sand> function, But I don't know how to format the characters to be diplayed in HTML, I got the results as:
www.parts<b>auto</b>.com (I couldn't replace the AscII characters with the HTML.)
source1Tamer
Posts: 91
Joined: Tue Nov 13, 2001 3:49 pm

Results Highlighting

Post by source1Tamer »

Note: I mean <sandr>
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

Results Highlighting

Post by Kai »

Query highlighting is just like a LIKE or LIKEP search in that a word will not be found as a substring of another word (except when using certain special pattern matchers), only as a distinct word itself, according to the Metamorph (<apicp>) settings currently in effect. If you use a wildcard after the word, eg. 'auto*', then it will match 'automobile', 'automags', etc.; just as LIKE/LIKEP would match.

To match 'auto' anywhere in a word, not just the start, use REX: '/auto'. (A slash introduces a REX expression; see the manual for Metamorph query syntax.) Note that REX has its own special characters; see the manual on REX syntax.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Results Highlighting

Post by mark »

Also note that REX is linear. Search this board and/or the manual for allinear.
source1Tamer
Posts: 91
Joined: Tue Nov 13, 2001 3:49 pm

Results Highlighting

Post by source1Tamer »

Actually I just wanted to highlight a few characters out of expression, it should be simpler..
Fortuanetly, I used the function <sum> to construct the <b> and </b> tags around the required word, so instead of having 'Auto' it will be '<b>Auto</b>' , then I've used the <sandr> to replace the 'Auto' with the new '<b>Auto</b>' ,, then I have used the <send> function to print the string as is without HTML escapment. I'm rockin now...
Post Reply