I feel like i'm making this harder than it is... I am making a page to input invoices. The page is going to show with only one "item" box, then there will be an "Add Item" button at the bottom. My problem is that I need each of those boxes to have its own name, and the value to be carried over each time you press the "Add Item" button.. here is the code I have so far... $add = $orig_add; $new_comp = $_POST['new_comp']; $orig_add = $_POST['orig_add']; $company = $_POST['company']; $inv_no = $_POST['inv_no']; ?> <html> <center> <?php if ('y' == $new_comp) { ?> <form method="post"> <table border="1"> <tr> <td colspan="1"> Company: </td> <td colspan="5"> <input type="text" name="company" value="<?php echo $company; ?>"></td> </tr> <tr> <td colspan="1"> Invoice Number: </td> <td colspan="5"> <input type="text" name="inv_no" value="<?php echo $inv_no; ?>"> </td> </tr> <tr> <td colspan="1"> Date Ordered: </td> <td colspan="5"> <?php echo monthselect(); echo dayselect(); echo yearselect(); ?> </td> </tr> <?php while ($add != 0) { $item = $_POST['item' . $add]?> <tr> <td> Item Description: </td> <td> <input type="text" name="<?php echo 'item' . $add; ?>" value="<?php echo 'item' . $add; ?>"> </td> <td> Quantity </td> <td> <input type="text" name="quantity" size="1" maxlength="3"> </td> <td> S/N?</td> <td> <select name="ser_no"> <option></option> <option value="y">Yes</option> <option value="n">No</option> </select> </td> </tr> <?php $add--; }?> </table> <table border="1"> <tr> <td> <form action="po.php" method="post"> <input type="hidden" name="new_comp" value="y"> <input type="hidden" name="orig_add" value="<?php echo $orig_add+1; ?>"> <input type="submit" value="Add Item"> </form> </td> <td> <form> <input type="hidden" name="update" value="new_comp"> <input type="submit" value="Submit Company"> </form> </td> </tr> <tr> <td> <?php echo $orig_add; ?> </td> </tr> </table> </form> <?php exit; } ?> PHP:
You can setup a session variable, and store all the items in that, and just pass the Session ID. Or, each time they add an item, write it to a database for storage.