Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

price compare

by bigup401 (Pilgrim)
on May 10, 2019 at 18:40 UTC ( #1233575=perlquestion: print w/replies, xml ) Need Help??

bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

am having above code. but need help. i want to select products on some price range like. if i select product and then select $200. it brings all products from $200 to $250.

#!/usr/bin/perl -w use CGI; use DBI; my $CGI = CGI->new(); my $host = "localhost"; my $usr = "root"; my $pwd = ""; my $dbname = "tbluser"; my $DBH = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { AutoCommit => 0, RaiseError => 1, }) or die $DBI::errstr; my $product_n = $CGI->param("productname"); my $product_t = $CGI->param("producttype"); my $price = $CGI->param("select"); my $CHECK = $DBH->prepare("SELECT SND.SELLER_ID, SND.SELLER_NAME, SND. +SELLER_COUNTRY, M.PRODUCT_ID, M.PRODUCT_NAME, M.PRODUCT_TYPE FROM PRODUCT_TABLE as M JOIN SELLERS_TABLE as SND ON SND.SELLER_ID = M.SELLER_ID WHERE M.PRODU +CT_NAME LIKE ? OR PRODUCT_TYPE LIKE ?"); $CHECK->execute('%'.$product_n.'%', '%'.$product_t.'%'); $RESLUTS = $CHECK->fetchall_arrayref(); + $DBH->disconnect || die "$DBI::errstr\n"; print "Content-type: text/html\n\n"; print <<START_HTML; <!DOCTYPE html> <html lang="en"> <head> <body> <form method="post"> <p>product name <input type="text" name="productname"> </p> <p>product type <input type="text" name="producttype"> </p> <p> <select name="select"> <option value="200">$200 - $25 +0</option> <option value="300">$300 - $40 +0</option> <option value="400">$400 plus< +/option> </select> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> </body> </html> HTML

Replies are listed 'Best First'.
Re: price compare
by stevieb (Abbot) on May 10, 2019 at 18:51 UTC

    Please stop making us guess as to what's happening.

    Your question should include, at minimum, 'what do I want?', 'what results I'm getting now', 'what results are incorrect', 'what input values I'm using' and 'this is what I've tried'.

      i think i got it solved :), by using sql select <= :html_param less than or equal to our price range AND NOT > :html_param greater than our price range

      so simple :D

        So it was an SQL question, not a Perl one?

        Just checking.


        Dave

Re: price compare
by FreeBeerReekingMonk (Deacon) on May 11, 2019 at 09:38 UTC
    is the mangled "RESULT" a freudian slip?
      Such typos are a defining quantity ... ehm .. quality of this monk. ;-)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      PS: It borders at trolling ... politely said.

      That's why I don't invest much more than voting and warning others.

Re: price compare
by harangzsolt33 (Pilgrim) on May 12, 2019 at 05:07 UTC
    If you're code contians typos, is no wonder your RESLUTS will be wrong. You might be able to red this, but computers r unforgiving. lol

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1233575]
Approved by philipbailey
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2019-06-26 00:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (108 votes). Check out past polls.

    Notices?