I can't replicate a problem with your inner if-statement. My feeling
is that the code isn't getting past the outer if-conditional.

   if ($main::global->{form}->{'setSearchBox'} eq $field
         || $main::global->{form}->{'setSearchBox'} eq 'both') {


If I were you I'd do something like

print STDERR "UPTO 1\n";

in various places to see what's actually being executed.

Andrew



On Sat, Sep 5, 2015 at 11:45 PM, SSC_perl <p...@surfshopcart.com> wrote:
>         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/
>
>



-- 
Andrew Solomon

Mentor@Geekuni http://geekuni.com/
http://www.linkedin.com/in/asolomon

--
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