Hello,
I have a profile with 5 categories in it. When user selects -Everything- option, I want to display number of results from each category at the top of the results page which shold be a link to those results.
How can I put a check box for each category, instead of a dropdown list?
You'd need to <loop> over the desired categories and do count() queries for each one to get the count. The link could be to a regular search of the selected category.
I used the following script in search function to get the number of hits in each category
<if $scq eq ''>
<LOCAL scq cq ic>
<$ic=$indexcount>
<BR>
<sql ROW "select distinct Catno scq,Category from categories order by convert(scq,'int')">
<SQL "select count(*) N " $sql>
<$cq=$scq> $scq,m <A HREF="$url$urlq$mltvar">$Category</A> $N
</SQL>
</sql>
<BR><BR>
<$indexcount=$ic>
</LOCAL>
</if>
Now I modified the search function little more so that the search form can accept more than one category. I modified it as follow:
<$cqq=>
<loop $cq>
<if $cq ne "">
<if $cqq eq "">
<$cqq=" and (">
<else>
<$cqq=$cqq " or">
</if>
<rex "\digit+" $cq>
<$cqq=$cqq " Catno matches '" $ret "'">
</if>
</loop>
<if $cqq ne ""><sum "%s" $cqq ")"><$cqq=$ret></if>
<$sql="from html
where Title\Description\Keywords\Meta\Body " $liketype " $$sq
and Title like $$stq
and Url matches $$suq
and Depth <= $$sdq
" $cqq>
Now thinkgs are working fine, I mean I can select multiple categories at a time and getting the results right. (I modified the script so that instead of dropdown list I have checkboxes for each category)
I am getting the search result all right except in the results per category. Instead of showing results in a particular category, I am getting total number of hits for the search in all the categories.
In my search file, first I have the code for accepting multiple categories then I have the code for hits in each category.