Good Morning Lai,

I've read through your doc and I'm starting to see what is happening.

I did a few things with my code to accomodate your code.

First, originally in my shop_parameters subroutine, I was doing a join between my two tables. I removed that join since we're creating another query that is extracting the colors into the array. Am I correct in doing that?

Second, I modified my code that produces the results into a table. When I run the script, I'm receiving the following message:
Can't call method "prepare" on an undefined value

I've pasted the code for the table with the results. I think I defined everything that needed to be defined. But, I'm not sure. Also, in your doc, you mentioned something about RTFM. What does that mean? Can you view the modified code again and spot check why I'm receiving that error message?

sub get_product_table { my $sth = shift; my ($dbh, $clref) = @_; my @row; my @nav_link; my ($color, @color); while (my $ref = $sth->fetchrow_hashref ()) { $clref = $dbh->prepare ("SELECT color FROM item WHERE p +rod_id = ".$ref->{product_id}); $clref->execute(); while (my $color = $clref->fetchrow_hashref()) { push @{$ref->{color}}, $color->{color}; } my $serve_url = sprintf ("serve_image.cgi?product_id=%s;picture", + escape ($ref->{product_id})); # generate a form allowing a quantity of the item to be added # to the cart push (@row, start_form(-method=>'POST', -action=>url()), hidden( -name => "choice", -override => 1, -default => "add" ), hidden( -name => "product_id", -override => 1, -default => escapeHTML($ref->{product_id})), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td (img ({-src => $serve_url, -alt => escapeHTML($ref->{product_id} +)})), td ({-width=>"80", -valign=>"top", -align => "center"}, escapeHTML( + $ref->{product_id} )), td ({-width=>"190", -valign=>"top"}, escapeHTML( $ref->{description +} ))), td (" "), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ({-colspan => "3", -align => "right", -style=>"font-weight: 700; + color:blue;"}, "Price: \$", escapeHTML( sprintf( "%.2f", $ref->{pri +ce}))), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ({-colspan => "3", -align => "right"}, "Colors:", popup_menu( -n +ame => "color", -values => $ref->{color}))), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ({-colspan => "3", -align => "right"}, "Quantity:", popup_menu( +-name => "quantity", -values => ["1", "2", "3", "4", "5", "6", "7", " +8", "9"])), td (image_button( -name => "Add Item", -src=>"../images/add.jpg", - +border=>"0" )))), Tr ({-valign=>"top"}, td ({-colspan=>"7", -width=>"100%"}, hr)), end_form() ); } $sth->finish (); return undef unless @row; # no items? return (table ({-border => 0, -align => "center", -style=>"font-fa +mily: verdana; font-size: 10pt;"}, @row)); }

Thanks again for your help. Oh, do you have any good recommendations for books that I can buy to learn more about Perl? There's so many of them out there, I don't know what's good or not.

Have a good day.

In reply to Re: Re^5: Joining Tables Problem by b310
in thread Joining Tables Problem by b310

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.