#!/usr/local/bin/perl ############################################################################# # nileListDet: List the detail of a specific order ############################################################################# use CGI "cookie"; # import CGI cookie function use DBI; $custid = cookie('custid'); # customer id = cookie (new way) if ($custid eq '') { # if cookie is not present &print_menu(); # reprint menu with error # exec "./nileSignin"; # (or) execute Signin pgm } &display_data(); exit; ########################################################################### sub print_menu { print "Content-type: text/html \n"; print "\n"; open(HTML, "<../../web/demo/perl/sql/nileMenu.html") || print ("Cannot open file - $!"); while ($line = ) { #print menu html print $line; } close(HTML); print "
"; print "You Must First Sign In!"; exit(-1); } ########################################################################### sub display_data { print "Content-type: text/html \n"; print "\n"; ($order_num) = @ARGV; # extract order_number from argument print " "; $dbh = DBI->connect("DBI:mysql:nile","nile","nile"); if (!defined($dbh)) { $msg = "Cannot open database connection - $DBI::errstr"; return; } $sql = "select o.order_num, o.prod_code, o.quantity, "; $sql .= " p.prod_desc, p.prod_price "; $sql .= " from orders_prod o, product p "; $sql .= " where o.order_num = $order_num "; $sql .= " and o.prod_code = p.prod_code "; $sql .= " order by prod_desc"; $cursor = $dbh->prepare($sql); $rc = $cursor->execute(); while( @columns = $cursor->fetchrow_array() ) { ($num,$prod_code,$quantity,$desc,$price) = @columns; print "
FlavorQuantityPrice
$desc$quantity$price"; $total += $quantity * $price; } print "
Total for Order$total  
"; } ###########################################################################