<div style="float:left;"> <!-- DIV creating table and populating with 100 Series --> <?php $sql = "SELECT * FROM blocks_table WHERE series='100 Series'"; $result = mysql_query($sql)or die(mysql_error()); $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)){ $type100 = $row['type']; $perpallet100 = $row['per_pallet']; $rowcounter++; // Now for each looped row echo "<tr><td>".$type100."</td> <td><input type='text' name='perpallet' id='perpallet$rowcounter' style='width:50px;' value='".$perpallet100."'/></td> <td><input type='text' name='quantity' id='quantity$rowcounter' style='width:50px;'/></td> <td><input type='text' name='pallets' id='pallets$rowcounter' style='width:50px;' onfocus='this.value=getTotal();'/></td> <td><input type='text' name='extras' style='width:50px;'/></td> </tr>"; } // End our while loop echo "</table>"; ?>
<!-- calculation --><script type="text/javascript"> var kavli = 0; function getTotal() { var total = 0; kavli++; var blockamount = 0; var perpallet = 0; blockamount = document.getElementById('quantity' + kavli); perpallet = document.getElementById('perpallet' + kavli); total = Math.floor(blockamount.value / perpallet.value); return total; }</script><!-- end calculation -->
<?php // connect to the database include('db.php')?><html><head><!-- calculation --><script type="text/javascript"> var kavli = 0; function getTotal() { var total = 0; kavli++; var blockamount = 0; var perpallet = 0; blockamount = document.getElementById('quantity' + kavli); perpallet = document.getElementById('perpallet' + kavli); total = Math.floor(blockamount.value / perpallet.value); return total; }</script><!-- end calculation --><title>HB - Block Order Tracking System</title><link rel="stylesheet" type="text/css" href="styles.css" /></head><body><img class="page-bg" src="page-bg.jpg"><img class="header-img"src="header-bg.png"><div id="wrap"> <center> <form action="insert-order.php" method="post"> <table class="styled-table"> <tr> <th>Order Date</th> <th>Company Name</th><th>Delivery Date</th> </tr> <tr> <td><input type="date" name="orderdate"></td> <td> <?php $query = mysql_query("SELECT company_name FROM client_table ORDER BY company_name"); echo "<select name=users>"; echo "<option value=blank selected></option>"; //for blank default option while ($r = mysql_fetch_array($query)) { $client = $r["company_name"]; echo "<option value=$client>$client</option>"; } echo "</select>"; ?> </td> <td><input type="date" name="deliverydate"></td> </tr> </table> <br /> <div style="float:left;"> <!-- DIV creating table and populating with 100 Series --> <?php $sql = "SELECT * FROM blocks_table WHERE series='100 Series'"; $result = mysql_query($sql)or die(mysql_error()); $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)){ $type100 = $row['type']; $perpallet100 = $row['per_pallet']; $rowcounter++; // Now for each looped row echo "<tr><td>".$type100."</td> <td><input type='text' name='perpallet' id='perpallet$rowcounter' style='width:50px;' value='".$perpallet100."'/></td> <td><input type='text' name='quantity' id='quantity$rowcounter' style='width:50px;'/></td> <td><input type='text' name='pallets' id='pallets$rowcounter' style='width:50px;' onfocus='this.value=getTotal();'/></td> <td><input type='text' name='extras' style='width:50px;'/></td> </tr>"; } // End our while loop echo "</table>"; ?> </div></form> </center></div></body></html>
<?phpinclude('db.php')?><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>HB - Block Order Tracking System</title><link rel="stylesheet" type="text/css" href="styles.css" /><script type="text/javascript"> function getTotal(idx) { var ppidx = 'perpallet'+idx; var qidx = 'quantity'+idx; var xidx = 'pallets'+idx; if (!document.getElementById(pidx)) { return false; } if (!document.getElementById(qidx)) { return false; } if (!document.getElementById(xidx)) { return false; } var p = document.getElementById(pidx).value; if ((p == '') || isNaN(p)) { return false; } var q = document.getElementById(qidx).value; q = parseInt(q, 10); var total = Math.ceil(q / p); document.getElementById(xidx).value = total; }</script></head><body><img class="page-bg" src="page-bg.jpg" alt="bg" /><img class="header-img" src="header-bg.png" alt="header" /><div id="wrap"> <form name="fmorder" action="insert-order.php" method="post"> <table class="styled-table"> <tr> <th>Order Date</th><th>Company Name</th><th>Delivery Date</th> </tr> <tr> <td><input type="text" name="orderdate" value="" /></td> <td> <?php $query = mysql_query("SELECT company_name FROM client_table ORDER BY company_name"); echo '<select name="users">'; echo '<option value="" selected="selected"></option>'; while ($r = mysql_fetch_array($query)) { echo '<option value="'.$r['company_name'].'">'.$r['company_name']."</option>"; } echo "</select>"; ?> </td> <td><input type="text" name="deliverydate" value="" /></td> </tr> </table> <br /> <div style="float:left;"> <?php $sql = "SELECT * FROM blocks_table WHERE series='100 Series'"; $result = mysql_query($sql)or die(mysql_error()); $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++; echo '<tr><td>'.$row['type'].'</td> <td><input type="text" name="perpallet'.$rowcounter.'" id="perpallet'.$rowcounter.'" style="width:50px;" value="'.$row['per_pallet'].'" /></td> <td><input type="text" name="quantity'.$rowcounter.'" id="quantity'.$rowcounter.'" style="width:50px;" value="" /></td> <td><input type="text" name="pallets'.$rowcounter.'" id="pallets'.$rowcounter.'" style="width:50px;" value="" onfocus="getTotal('.$rowcounter.');" /></td> <td><input type="text" name="extras" value="" style="width:50px;" /></td> </tr>'; } echo '</table>'; ?> </div></form></div></body></html>
<?php // connect to the database include('db.php');$insert="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]')";?> <html><head><title>HB - Block Order Tracking System</title><link rel="stylesheet" type="text/css" href="styles.css" /></head><body><img class="header-img"src="header-bg.png"> <div id="wrap"> <?php if(mysql_query($insert)){ echo "Record Added"; }else{ die('Error: ' . mysql_error()); } ?> <div id="centerDiv"> <ul class="centerUL"> <li><a href="index.html" class="button">Back</a></li> </ul> </div> </div></div></body></html>
<?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');}?>