I want to know how can you submit data to a dynamic table and then when the table is full it needs to be inserted into the database. The users here scan in voucher barcodes. Each barcode is linked to a GRN number and a Customer number. They get a pack of vouchers and scan then in with a scanner. I have created a form page in php to scan this in to the $_SESSION variable.
if(isset($_POST['add']) and $_POST['add'] == "Add Item" and $_POST['fl_voucher_no'] != "" and $_POST['fl_voucher_grn'] != "")
{
$_SESSION['grn'] = $_POST['fl_voucher_grn'];
$_SESSION['date'] = $_POST['fl_voucher_date'];
$_SESSION['voucher_cust'] = $_POST['fl_voucher_customer'];
$_SESSION['voucher_no'][] = $_POST['fl_voucher_no'];
header('Location: .');
}
since the scanner presses 'enter' every time the page reloads and they scan in the next number.
When they have scanned all the vouchers they submit to the database.
Is this the best way to do it with the $_SESSION variable or how else would you suggest one goes about this?
I would use javascript (jQuery) and prevent the form submission (due "enter" from scanner) and go to the next form field instead. (create the next form field dynamically when it doesn't exist yet.)
When finished scanning submit all fields at once.