Its me again. xD
I have this:
[php]
<?php include ("dbc.php"); $key = $_POST['item']; $jobid =filter($_POST['jid']); $add1 = filter($_POST["add1"]); $add2 = filter($_POST["add2"]); $add3 = filter($_POST["add4"]); $pc = filter($_POST["pc"]); $from = filter($_POST["from"]); $to = filter($_POST["to"]); $equipment = filter($_POST["equipment"]); $cname = filter($_POST["cname"]); $del = filter($_POST["deliver"]); foreach($key as $value){ $i = ltrim($value['code'], "0"); $q = $value['quantity']; $d = $value['desc']; $p = $value['price']; $tp = $value['totalprice']; echo "I: ".$i.""; echo "Q: ".$q.""; echo "D: ".$d.""; echo "P: ".$p.""; echo "TP: ".$tp.""; echo "jobid: ".$jobid.""; $sql = "INSERT INTO job_items (job_id, quantity, product_id, unit_price, description, total) VALUES ('$jobid', '$q', '$i', '$p', '$d', '$tp');"; $result = mysql_query($sql); } $sql = "INSERT INTO jobs (job_id, address1, address2, address3, postcd, cid, deliver, fromdate, todate) VALUES ('$jobid', '$add1', '$add2', '$add3', '$pc', '$cname', '$del', '$from', '$to');"; mysql_query($sql); if(!$result ){ die('Could not update data: ' . mysql_error()); } echo "Job inserted successfully\n"; ?>[/php]
Is there a better way to do it? I feel that its a bit of a hack. It works though.