Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:27:30+00:00 2026-06-10T12:27:30+00:00

I am writing a script that will take some form data and present it

  • 0

I am writing a script that will take some form data and present it in a PDF or some other printable format. At the bottom of the form is a “New Line” button. When you click this button a new line in the form appears, and the data in the previous line is added to an array named according to its label tag. My problem is that when the form is submitted the only data that ends up in the $desc[] array is what ever was entered in the last row. can someone please look over my code and see what I may have done wrong?

if (isset($_POST['new_line']) || isset($_POST['submit'])) {

    // Grab POST data
    $invoice_quote = trim($_POST['invoice_quote']);
    $sales_person = trim($_POST['sales_person']);
    $job = trim($_POST['job']);
    $due_date = trim($_POST['due_date']);
    $first_name = trim($_POST['first_name']);
    $last_name = trim($_POST['last_name']);
    $address = trim($_POST['address']);
    $city = trim($_POST['city']);
    $state = trim($_POST['state']);
    $zip = trim($_POST['zip']);
    $phone = trim($_POST['phone']);
    $email = trim($_POST['email']);
    $qty = array_filter(array_map('trim', $_POST['qty']));
    $desc = array_filter(array_map('trim', $_POST['desc']));
    $unit_price = array_filter(array_map('trim', $_POST['unit_price']));
    $line_total = array_filter(array_map('trim', $_POST['line_total']));
    $line = trim($_POST['line']);



    if (isset($_POST['submit'])) {
        $flag = 'FALSE';

        // This is only for test proposes, This is untimately where the 
        // code will go that will generate the PDF
        echo ('<div class= "info">'.$invoice_quote.' '.$sales_person.' '.$job.' '.$due_date.' '.$first_name.' '.$last_name.' '.$address.' '.$city.' '.$state.' '.$zip.' '.$phone.' '.$email.'<br />');
        var_dump($qty);
        echo '<br />';
        var_dump($desc);
        echo '<br />';
        var_dump($unit_price);
        echo '<br />';
        var_dump($line_total);
        echo('</div>');
        exit();

      }

}

<form id="invoiceform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset class= "description">
                            <label for= "qty" class= "qty">Qty</label>
                            <label for= "desc" class= "desc">Description</label>
                            <label for= "unit_price" class= "unit_price">Unit Price</label>
                            <label for= "line_total" class= "line_total">Line Total</label>
                            <br/>
                    <?php
                        if ($flag == 'TRUE') {
                            $n = 0;
                            do {
                    ?>
                                <input type= "text" class= "qtyinfo" name= "qty[]" maxlength "10" value= "<?php if (isset($qty[$n])) echo ($qty[$n]); ?>"/>
                                <textarea class= "descinfo" name= "desc[]" id="<?php echo('desc_'.$n); ?>" value= "<?php if (isset($desc[$n])) echo ($desc[$n]); ?>"></textarea>
                                <input type= "text" class= "unit_priceinfo" name= "unit_price[]" id="<?php echo('unit_price_'.$n); ?>" maxlength= "10" value= "<?php if (isset($unit_price[$n])) echo ($unit_price[$n]); ?>" />
                                <input type= "text" class= "line_totalinfo" name= "line_total[]" id= "<?php echo('line_total_'.$n); ?>" maxlength= "10" value= "<?php if (isset($line_total[$n])) echo ($line_total[$n]); ?>" />
                                <br/>
                    <?php
                                $n++;
                            }
                            while ($n < $line);
                        }
                    ?>



                <input type= "hidden" id= "line" name= "line" value= "<?php echo $line + 1; ?>"/>
                <input type= "submit" id= "new_line" name= "new_line" value= "New Line" />
            </fieldset><br />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:27:31+00:00Added an answer on June 10, 2026 at 12:27 pm

    try it:

    <textarea id= "desc" name=  "<?php echo('desc_'.$n); ?>"><?php if (isset($desc[$n])) echo ($desc[$n]); ?></textarea>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a script that will constantly scan iTunes for new dialog boxes and
I am writing a bash script for an automator service that will take a
I am writing a script that will be polling a directory looking for new
I'm writing a Powershell script that will extract a set of data files from
I'm writing a php script that will fetch data from a given URL and
I'm writing a utility script that will take a column from a database table
I am writing an awk script that will take the output of grep and
I'm writing a script that will take a filename as an argument, find a
I am writing a script that will look in a custom reports directory, copy
I'm writing a script that will ping my ip range. Here's what I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.