I have various forms which collect data and is stored in sessions until the user reaches the final page where all the information is input into 2 queries.
The data goes into 2 linked tables transaction_master and transaction detail.
I have no problem getting data into the first table, but i am having trouble with the transaction_detail table. As the number of rows that will be entered by the user is different each time.
So i set the names in the form for the transaction lines as arrays by adding. Now what i need to know is how to loop that information into the array. The code i have up to now is below:
<?php include('header.php'); include('auth.php'); /* Transaction master table Variables*/ $paymenttype = $_POST['paymenttype']; $invoiceissued = $_POST['invoiceissued']; $invoicenumber = $_POST['invoicenumber']; $trx = "null"; $logdate = $_SESSION['entrydate']; $saledate = $_SESSION['saledate']; $soldby = $_SESSION['soldby']; $student = $_SESSION['student']; $contractnumber =$_SESSION['contractnumber']; $notes = $_SESSION['notes']; $splitwith = $_SESSION['splitwith']; /* Transaction detail Variables*/ $serviceid = $_SESSION['service']; $details = $_SESSION['details']; $start = $_SESSION['startdate']; $end = $_SESSION['enddate']; $updatedend = $_SESSION['enddate']; $hoursquantity = $_SESSION['quantity']; $price = $_SESSION['price']; $hoursused = "0"; include ('connect.php'); $tmquery = "INSERT INTO `transaction_master`(`TM_TRX`, `TM_Log_Date`, `TM_Actual_Sale_Date`, `TM_Sales_Rep_ID`, `TM_Customer_ID`, `TM_Contract_Number`, `TM_Payment_Type`, `TM_Invoice_Issued`, `TM_Invoice_Number`, `TM_Notes`, `TM_Splitwith`) VALUES ('$trx','$logdate','$saledate','$soldby','$student','$contractnumber','$paymenttype','$invoiceissued','$invoicenumber','$notes','$splitwith')"; mysql_query($tmquery)or die (' TM Error updating database'); echo "TM Data gone in"; $transmasterid = mysql_insert_id(); // i need to now loop the arrays in to the following query line by line $tdquery = "INSERT INTO `transaction_detail`(`TD_ID`, `TD_Service ID`, `TD_Details`, `TD_Start`, `TD_End`, `TD_Updated_End`, `TD_Hours/Quantity`, `TD_Price/hr`, `TD_Hours_Used`)VALUES ('$transmasterid','$serviceid','$details','$start','$end','$updatedend','$hoursquantity','$price','$hoursused')"; mysql_query($tdquery)or die (' TD line Error updating database'); echo "TD Data gone"; ?>