in reply to looking for better solution

Thanks frank.. i'll look into Html::Template. Sorry for the ambiguity about the data. I am pulling the data from a database from our main business system (pervasive-SQL) and a table in there that stores all of the work orders for our shop. So in my call i pull all of the lines that have a possibility of being sent out for processing. That's where i need to create this bill of lading and e-mail it to the vendor. Not all of the lines of data are sent to the vendor. Only the lines that the user enters a number into. SO i need to detect which lines have a skid and part qty, stick that into an e-mail and send.. ( using Mail::Sender ) That mail is not a problem.. the main question is how to only grab the appropriate lines from the table and put it into an array..

Replies are listed 'Best First'.
Re^2: looking for better solution
by eric256 (Parson) on Nov 01, 2007 at 14:32 UTC

    Couldn't you use a where clause in the sql query to only grab the ones with quantity and skid set?

    Your code is pretty confusing for a couple reasons. The use of print mixed in with your insertion of text into an array ref mixed with that incrementing variable makes it hard to follow.

    The following does the same thing as your code does, but I think it makes it clear exactly what is going on. I'm still confused by the mix of printing plain text with HTML, and the strings your are putting into the array are odd as well.

    my $ordno = 1; while (my $ref = $GetWOData->fetchrow_hashref()) { print "$ref->{'Ord_No'}\n"; print "$ref->{'Item_No'}\n"; print "<input type=\"text\" name=\"qty$ordno\" value=\"\" size=\ +"6\">\n"; #Qty of parts print "$ref->{'Item_Desc_1'}\n"; print "<input type=\"text\" name=\"skd$ordno\" value=\"\" size=\ +"6\">\n"; #Num of skids print "$ref->{'Cus_Name'}\n"; push @{$orders[$ordno]}, "$ref->{'Ord_No'} | $ref->{'Item_No'}"; push @{$orders[$ordno]}, "0"; push @{$orders[$ordno]}, "$ref->{'Item_Desc_1'} | $ref->{'Item_Desc_ +2'}"; push @{$orders[$ordno]}, "0"; push @{$orders[$ordno]}, "$ref->{'Cus_Name'}"; $ordno++; } $GetWOData->finish();

    ___________
    Eric Hodges
      Thanks.. i'll use the push method to build the array.

      I think i found a solution to what i want to do.. Using CGI::Ajax i think i can output this table with the form elements, and then only put items in the array when they enter data.

      The query problem is that the Quantity can change on the Floor (Scrap) and Skid quantity will also change dynamically so i can't grab that data.. i have to rely on users to input that

      I will post final outcome once i work out all of the little details..

        It sounds like you might be a little confused about the flow of CGI.

        Your perl script generates an HTML form, when submitted that form sends the data back to which ever script you want (by calling that script agian) which would then generate another HTML page and the email. So when processing the return from the script you will know the quantities and skids.


        ___________
        Eric Hodges