<?php $sql = "SELECT * FROM blocks_table WHERE series='100 Series'"; // 100 SERIES -------------------------------------------------------------------- $result = mysql_query($sql)or die(mysql_error()); $series = 100; $rowcounter = 0; echo '<table class="styled-table">'; echo '<tr><th>100 Series</th><th>Per Pallet</th><th>Quantity</th><th>Pallets</th><th>Extras</th></tr>'; while($row = mysql_fetch_array($result)){ $rowcounter++; $output = <<<DATADATA <tr><td>{$row["type"]}</td></td> <td><input type="text" name="{$series}perpallet[{$rowcounter}]" id="{$series}perpallet{$rowcounter}" style="width:50px;" value="{$row['per_pallet']}" readonly /></td> <td><input type="text" name="{$series}quantity[{$rowcounter}]" id="{$series}quantity{$rowcounter}" style="width:50px;" value="0" onChange="getTotal({$series},{$rowcounter});" /></td> <td><input type="text" name="{$series}pallets[{$rowcounter}]" id="{$series}pallets{$rowcounter}" style="width:50px;" value="0" class="pallets" readonly /></td> <td><input type="text" name="{$series}extras[{$rowcounter}]" id="{$series}extras{$rowcounter}" style="width:50px;" value="0" class="extras" readonly /></td> </tr>DATADATA; echo $output;} echo '</table>'; ?>
<?phpprint_r($_POST); ?>
Array ( [companyname] => NACA [deliveryaddress] => Stuart Park [orderdate] => 2013-04-18 [deliverydate] => 2013-05-16 [status] => Completed [checked] => Yes [loadedby] => MANOLIS [sumpallets] => 3 [sumextras] => 624 [makeup] => 2 [grandtotal] => 5 [submit] => Submit Order [100perpallet] => Array ( [1] => 180 [2] => 240 [3] => 360 [4] => 576 [5] => 144 [6] => 288 [7] => 280 [8] => 560 [9] => 360 [10] => 480 [11] => 720 [12] => 1152 ) [100quantity] => Array ( [1] => 654 [2] => 154 [3] => 356 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [100pallets] => Array ( [1] => 3 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [100extras] => Array ( [1] => 114 [2] => 154 [3] => 356 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) )
<?phpinclude('db.php'); //connectprint_r($_POST); foreach($_POST AS $key=>$value) { $sql="INSERT INTO order_table ('extra_blocks') VALUES ('$_POST[sumextras]')"; $result = mysql_query($sql) or die("didn't work");}?>
<?phpinclude('db.php'); //connect//print_r($_POST); echo '<pre style="text-align: left;">' . print_r($_POST, true) . '</pre>';foreach($_POST["id"] AS $key=>$value) { $sql="INSERT INTO order_table ('company_name') VALUES ('$_POST[companyname]')"; $result = mysql_query($sql) or die("didn't work");}?>
Array( [companyname] => InfoShell [deliveryaddress] => Kavlia street [orderdate] => 2013-04-18 [deliverydate] => 2013-05-23 [status] => Pending [checked] => No [loadedby] => Kavlifei [sumpallets] => 3 [sumextras] => 187 [makeup] => 1 [grandtotal] => 4 [submit] => Submit Order [100perpallet] => Array ( [1] => 180 [2] => 240 [3] => 360 [4] => 576 [5] => 144 [6] => 288 [7] => 280 [8] => 560 [9] => 360 [10] => 480 [11] => 720 [12] => 1152 ) [100quantity] => Array ( [1] => 354 [2] => 245 [3] => 368 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [100pallets] => Array ( [1] => 1 [2] => 1 [3] => 1 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [100extras] => Array ( [1] => 174 [2] => 5 [3] => 8 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ))didn't work
[companyname] => InfoShell [deliveryaddress] => Kavlia street [orderdate] => 2013-04-18 [deliverydate] => 2013-05-23 [status] => Pending [checked] => No [loadedby] => Kavlifei [sumpallets] => 3 [sumextras] => 187 [makeup] => 1 [grandtotal] => 4 [submit] => Submit Order
[100perpallet] => Array ( [1] => 180 [2] => 240 [3] => 360 [4] => 576 [5] => 144 [6] => 288 [7] => 280 [8] => 560 [9] => 360 [10] => 480 [11] => 720 [12] => 1152 ) [100quantity] => Array ( [1] => 354 [2] => 245 [3] => 368 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [100pallets] => Array ( [1] => 1 [2] => 1 [3] => 1 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [100extras] => Array ( [1] => 174 [2] => 5 [3] => 8 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 )
<?phpinclude('db.php'); //connectecho '<pre style="text-align: left;">' . print_r($_POST, true) . '</pre>';mysql_query("INSERT INTO order_table (company_name, delivery_address, order_date, delivery_date, status, hb_checked, loaded_by, pallets, extra_blocks, extra_pallets, total_pallets)VALUES('$_POST[companyname]','$_POST[deliveryaddress]','$_POST[orderdate]','$_POST[deliverydate]','$_POST[status]','$_POST[checked]','$_POST[loadedby]','$_POST[sumpallets]','$_POST[sumextras]','$_POST[makeup]','$_POST[grandtotal]')");$currentid = mysql_insert_id();foreach($_POST['100type'] AS $key=>$value) {$sql = "INSERT INTO order_details_table(order_id, block_type, block_quantity, block_pallets, block_extras)VALUES ('$currentid', '{$_POST['100type'][$key]}','{$_POST['100quantity'][$key]}','{$_POST['100pallets'][$key]}','{$_POST['100extras'][$key]}')";$result = mysql_query($sql) or die('Could not insert data');}?>