I've run across something that seems strange to me and I'm hoping 
someone has seen this before.  In SurfShop, you can search the product database 
by either item #, product name, or full description.  When searching by item 
id, let's say 'AM', the code will find any part # with the letters 'A' and 'M' 
in it, e.g. 'ATXM3'.  If you add an equals sign to the start of the product #, 
i.e. '=AM', it will find all items with the letters 'AM', in that order.  If 
you append two equals signs, i.e. '==AM', it will return that record only.

        Depending on the size of the products db, performing an item # search 
without prepending '=' can return a long list, so I'd like to have the code add 
that automatically.  In the snippet below, I added the section with the <---.  
It works perfectly fine, until you try to search for only numbers.  If you were 
to do a search for, say '1234', $main::global->{form}->{'searchtext'} will be 
blank on the search page, where it's displayed.

        The strange part is that if I remove the <--- code and just add the 
equals sign manually in the search field, everything works normally.  So the 
code apparently doesn't like a number prepended with an equals sign.  Why would 
that be, and how can I get it to work?  When I ran a test script appending = to 
a number, it seemed to work just fine, so I'm at a loss.

        I hope this is enough to go on.  If not, please let me know.

Thanks,
Frank



foreach my $field (@fieldnames) {
        if ($main::global->{form}->{'setSearchBox'} eq $field 
         || $main::global->{form}->{'setSearchBox'} eq 'both') {
           
                if ($field eq 'itemid' 
                 && $main::global->{form}->{'searchtext'} !~ m/^=|\*|\%/
                 && $main::global->{config}->{'useDBM'} eq 'sql') 
                {
                        $main::global->{form}->{'searchtext'} = 
"=$main::global->{form}->{'searchtext'}";  # <---
                }
                
                $search->{$field} = $main::global->{form}->{'searchtext'};
                $searchparams++;
        }
}


SurfShopCART 2
http://www.surfshopcart.com/u/demo


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to