Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting multiple records to a table simultaneously

Status
Not open for further replies.

deeciple

Technical User
Mar 1, 2012
70
US
Hi All,

I have the following javascript code to dynamically create a table and populate it with data. Each time the user presses the "Add Row" button on my form, the addrow function is called and a row containing their data is added to the table. Here is the code:
JavaScript:
<SCRIPT language="javascript">         
function addRow(tableID) {
    if (!document.getElementById(tableID)) {

        var body = document.getElementsByTagName("fieldset")[2];
        var tbl = document.createElement("table");
        var tblBody = document.createElement("tbody");
        
        tbl.appendChild(tblBody);
        body.appendChild(tbl);

        tbl.setAttribute("id", "dataTable");
        tbl.setAttribute("border", "0");
        }

    var StartTime = document.getElementById('txtStartTime');
    var EndTime = document.getElementById('txtEndTime');
    var MaterialID = document.getElementById('txtMaterialID');
    var Title = document.getElementById('txtTitle');               
    
    var table = document.getElementById(tableID);               
    
    var rowCount = table.rows.length;             
    var row = table.insertRow(rowCount);
 
    var cell1 = row.insertCell(0);
	var element1 = document.createElement("input");
    element1.type = "checkbox";             
    cell1.appendChild(element1);               
    
    var cell2 = row.insertCell(1);
    var element2 = document.createElement("input");
    element2.className="ShortField";             
    element2.type = "text";
    element2.setAttribute("name","StartTime");
	element2.setAttribute("readonly","true");
    element2.value = StartTime.value;             
    cell2.appendChild(element2);
    StartTime.value="";              
    
    var cell3 = row.insertCell(2);
    var element3 = document.createElement("input");
    element3.className="ShortField";             
    element3.type = "text";
    element3.setAttribute("name","EndTime");
	element3.setAttribute("readonly","true");
    element3.value = EndTime.value;             
    cell3.appendChild(element3);
    EndTime.value=""; 

    var cell4 = row.insertCell(3);
    var element4 = document.createElement("input");
    element4.className="ShortField";             
    element4.type = "text";
    element4.setAttribute("name","MaterialID")
	element4.setAttribute("readonly","true");
    element4.value = MaterialID.value;            
    cell4.appendChild(element4);
    MaterialID.value="";               
    
    var cell5 = row.insertCell(4);
    var element5 = document.createElement("input");
    element5.className="LongField";             
    element5.type = "text";
    element5.setAttribute("name","Title");
	element5.setAttribute("readonly","true");
    element5.value = Title.value; 
    cell5.appendChild(element5);
    Title.value="";
	    
	var cell6 = row.insertCell(5);
    var element6 = document.createElement("input");
    element6.className="ShortField";             
    element6.type = "text";
    element6.setAttribute("name","row");
	element6.setAttribute("readonly","true")
	element6.style.display = "none";
    element6.value = table.rows.length; 
    cell6.appendChild(element6);
}           
function deleteRow(tableID) {
	if (document.getElementById(tableID)) {
    try {             
        var table = document.getElementById(tableID);             
        var rowCount = table.rows.length;               
        for(var i=0; i<rowCount; i++) {                 
            var row = table.rows[i];                 
            var chkbox = row.cells[0].childNodes[0];                 
            if(null != chkbox && true == chkbox.checked) {                     
                table.deleteRow(i);                     
                rowCount--;                     
                i--;                 
            }               
        }             
    }catch(e) {                 
        alert(e);             
    }         
}
}
function updateRow(tableID) {
    if (document.getElementById(tableID)) {

    var StartTime = document.getElementById('txtStartTime');
    var EndTime = document.getElementById('txtEndTime');
    var MaterialID = document.getElementById('txtMaterialID');
    var Title = document.getElementById('txtTitle');
    try {             
        var table = document.getElementById(tableID);             
        var rowCount = table.rows.length;               
        for(var i=0; i<rowCount; i++) {                 
            var row = table.rows[i];                 
            var chkbox = row.cells[0].childNodes[0];                 
            if(null != chkbox && true == chkbox.checked) {                     
                //table.deleteRow(i);
                chkbox.checked=false;
                row.cells[1].childNodes[0].value=StartTime.value;
                row.cells[2].childNodes[0].value=EndTime.value;
                row.cells[3].childNodes[0].value=MaterialID.value;
                row.cells[4].childNodes[0].value=Title.value;
            }               
        }
        StartTime.value="";
        EndTime.value="";
        MaterialID.value="";
        Title.value="";              
    }catch(e) {                 
        alert(e);             
    }         
}
}        
</SCRIPT>

This is working fine on my form but I am having trouble with the php processing script. I am having trouble with $query2. Please ignore the commented areas. They are for future headaches lol. Here is my processing script:

PHP:
?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php
	/*
	$errors = array();
	
	// Form Validation
	$required_fields = array('List1', 'List2', 'Airdate', 'Description', 'Resolution');
	foreach($required_fields as $fieldname) {
		if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) {
			$errors[] = $fieldname;
		}
	}


	$fields_with_lengths = array('menu_name' => 30);
	foreach($fields_with_lengths as $fieldname => $maxlength ) {
		if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
	}


	if (!empty($errors)) {
		redirect_to("errors.html");
	}
	*/
?>

<?php
	$DiscrepType = mysql_prep($_POST['List1']);
	$DiscrepDetail = mysql_prep($_POST['List2']);
	$Airdate = $_POST['Airdate'];
	$Description = mysql_prep($_POST['Description']);
	$Resolution = mysql_prep($_POST['Resolution']);
	$OnAirVariance = mysql_prep($_POST['OnAirVariance']);
	$EquipID = mysql_prep($_POST['EquipID']);
	$EquipLoc = mysql_prep($_POST['EquipLoc']);
	$StartTime = array (mysql_prep($_POST['StartTime']));
	$EndTime = array (mysql_prep($_POST['EndTime']));
	$MaterialID = array (mysql_prep($_POST['MaterialID']));
	$Title = array (mysql_prep($_POST['Title']));
	$Row = array ($_POST['Row']);

	/*
	$INISatNSS806 = $_POST['INISatNSS806'];
	$LaFamilia = $_POST['LaFamilia'];
	$G15Analog = $_POST['G15Analog'];
	$G15Digital = $_POST['G15Digital'];
	$DirecTV = $_POST['DirecTV'];
	$DISH = $_POST['DISH'];
	$INSPhits = $_POST['INSPhits'];
	$INSPolym = $_POST['INSPolym'];
	$HalHDgal15 = $_POST['HalHDgal15'];
	$HalGal15 = $_POST['HalGal15'];
	$HalOlym = $_POST['HalOlym'];
	$HalHits = $_POST['HalHits'];
	*/
?>
<?php
	$query1 = "INSERT INTO tblonairactivity (
			DiscrepType, DiscrepDetail, Airdate, Description, Resolution, OnAirVariance, EquipID, EquipLoc
			) VALUES (
			'{$DiscrepType}', '{$DiscrepDetail}', '{$Airdate}', '{$Description}', '{$Resolution}', '{$OnAirVariance}', '{$EquipID}', '{$EquipLoc}'
			)";

	  foreach($Row as $index) {
			$query2 = "INSERT INTO tblAffectedProg (tblOnAirActivityID, StartTime, EndTime, MaterialID, Title
	        	) VALUES (
	        	LAST_INSERT_ID(), '{$StartTime}', '{$EndTime}', '{$MaterialID}', '{$Title}';
/*
	$query3 = "INSERT INTO tblsatellites (
				INISatNSS806, LaFamilia, G15Analog, G15Digital, DirecTV, DISH, INSPhits, INSPolym, HalHDgal15, HalGal15, HalOlym, HalHits
			) VALUES (
				{$INISatNSS806}, {$LaFamilia}, {$G15Analog}, {$G15Digital}, {$DirecTV}, {$DISH}, {$INSPhits}, {$INSPolym}, {$HalHDgal15}, {$HalGal15}, {$HalOlym}, {$HalHits}
			)";
*/	
	$result = FALSE;
	if (mysql_query('BEGIN')) {
	    if (mysql_query($query1) &&
	        mysql_query($query2))
	        $result = mysql_query('COMMIT'); // both queries looked OK, save
	    else
	        mysql_query('ROLLBACK'); // problems with queries, no changes.
	    }

	if ($result) {
		// Success!
		redirect_to("success.html");
	} else {
		// Display error message.
		echo "<p>Record creation failed.</p>";
		echo "<p>" . mysql_error() . "</p>";
	}
?>

<?php mysql_close($connection); ?>
I am getting the following error:
Parse error: syntax error, unexpected T_STRING in C:\wamp\ on line 70

The strange thing is that line #70 is in one of the commented areas. How can this be? Can anyone please help me figure out what I am missing here?

Thanks,

Ken
 
OK I fixed all the careless errors and got it to insert to my table, but only one record is being inserted (instead of all the records from my form's table)and the values that are being saved is "Array" for each field.

HELLLLP!!!
 
Are you sure your variables are arrays?

I would start by echoing out your POST variable so you know exactly what you are receiving from your form.

Try:

Code:
echo "<pre>" . print_r($_POST,1) . "</pre>";

With that said, you are never telling the inputs to be arrays when you create them. They all have the same variable name so in essence they are overwriting the value with each row when the form is submitted. At the end you only have one single set of inputs from the last added row.

Give your new elements square brackets as part of their name, so when they are submitted, PHP can recognize they are actual arrays, and treat them as such. You'll also have to loop through them though.

i.e
Code:
element3.setAttribute("name","EndTime[red][][/red]");

And in PHP:

PHP:
$pos=-1;
foreach($Row as $index) {
$pos++;
			$query2 = "INSERT INTO tblAffectedProg (tblOnAirActivityID, StartTime, EndTime, MaterialID, Title
	        	) VALUES (
	        	LAST_INSERT_ID(), '{$StartTime[red][$pos][/red]}', '{$EndTime[red][$pos][/red]}', '{$MaterialID[red][$pos][/red]}', '{$Title[red][$pos][/red]}';



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Vacunita,

Thank you for your corrections :) I am out of the office right now but as soon as I return I will try your suggestions and post back.

Best regards,

Ken
 
I worked on it a little more but I am still stuck on an error:

error said:
Parse error: syntax error, unexpected $end in C:\wamp\ on line 100

Here is my process script so you can see what's going on:

PHP:
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php
	/*
	$errors = array();
	
	// Form Validation
	$required_fields = array('List1', 'List2', 'Airdate', 'Description', 'Resolution');
	foreach($required_fields as $fieldname) {
		if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) {
			$errors[] = $fieldname;
		}
	}


	$fields_with_lengths = array('menu_name' => 30);
	foreach($fields_with_lengths as $fieldname => $maxlength ) {
		if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
	}


	if (!empty($errors)) {
		redirect_to("errors.html");
	}
	*/
?>

<?php
	$DiscrepType = mysql_prep($_POST['List1']);
	$DiscrepDetail = mysql_prep($_POST['List2']);
	$Airdate = $_POST['Airdate'];
	$Description = mysql_prep($_POST['Description']);
	$Resolution = mysql_prep($_POST['Resolution']);
	$OnAirVariance = mysql_prep($_POST['OnAirVariance']);
	$EquipID = mysql_prep($_POST['EquipID']);
	$EquipLoc = mysql_prep($_POST['EquipLoc']);
	$StartTime = array (mysql_prep($_POST['StartTime']));
	$EndTime = array (mysql_prep($_POST['EndTime']));
	$MaterialID = array (mysql_prep($_POST['MaterialID']));
	$Title = array (mysql_prep($_POST['Title']));
	$Row = array ($_POST['Row']);

	/*
	$INISatNSS806 = $_POST['INISatNSS806'];
	$LaFamilia = $_POST['LaFamilia'];
	$G15Analog = $_POST['G15Analog'];
	$G15Digital = $_POST['G15Digital'];
	$DirecTV = $_POST['DirecTV'];
	$DISH = $_POST['DISH'];
	$INSPhits = $_POST['INSPhits'];
	$INSPolym = $_POST['INSPolym'];
	$HalHDgal15 = $_POST['HalHDgal15'];
	$HalGal15 = $_POST['HalGal15'];
	$HalOlym = $_POST['HalOlym'];
	$HalHits = $_POST['HalHits'];
	*/
?>
<?php
	$query1 = "INSERT INTO tblonairactivity (
			DiscrepType, DiscrepDetail, Airdate, Description, Resolution, OnAirVariance, EquipID, EquipLoc
			) VALUES (
			'{$DiscrepType}', '{$DiscrepDetail}', '{$Airdate}', '{$Description}', '{$Resolution}', '{$OnAirVariance}', '{$EquipID}', '{$EquipLoc}'
			)";
		
//	$lastID = LAST_INSERT_ID()

	$pos = -1;
	foreach($Row as $index) {
	$pos++;
	$query2 = "INSERT INTO tblAffectedProg (tblOnAirActivityID, StartTime, EndTime, MaterialID, Title
	        	) VALUES (
	        	LAST_INSERT_ID(), '{$StartTime[$pos]}', '{$EndTime[$pos]}', '{$MaterialID[$pos]}', '{$Title[$pos]}';
	        	}";
/*
	$query3 = "INSERT INTO tblsatellites (
				INISatNSS806, LaFamilia, G15Analog, G15Digital, DirecTV, DISH, INSPhits, INSPolym, HalHDgal15, HalGal15, HalOlym, HalHits
			) VALUES (
				{$INISatNSS806}, {$LaFamilia}, {$G15Analog}, {$G15Digital}, {$DirecTV}, {$DISH}, {$INSPhits}, {$INSPolym}, {$HalHDgal15}, {$HalGal15}, {$HalOlym}, {$HalHits}
			)";
*/	
	$result = FALSE;
	if (mysql_query('BEGIN')) {
	    if (mysql_query($query1) &&
	        mysql_query($query2))
	        $result = mysql_query('COMMIT'); // both queries looked OK, save
	    else
	        mysql_query('ROLLBACK'); // problems with queries, no changes.
	    }

	if ($result) {
		// Success!
		redirect_to("success.html");
	} else {
		// Display error message.
		echo "<p>Record creation failed.</p>";
		echo "<p>" . mysql_error() . "</p>";
	}
?>

<?php mysql_close($connection); ?>
 
The error means that you placed it somewhere it wasn't expected, not that there's something wrong with the line.

Show me the code around it and I may be able to tell you why.

As a start make sure all preceding lines ate correctly terminated with a semi colon, and you aren't missing any brackets anywhere.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I got the error taken care of but I am still having trouble. Here is my code:

PHP:
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php
	/*
	$errors = array();
	
	// Form Validation
	$required_fields = array('List1', 'List2', 'Airdate', 'Description', 'Resolution');
	foreach($required_fields as $fieldname) {
		if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) {
			$errors[] = $fieldname;
		}
	}


	$fields_with_lengths = array('menu_name' => 30);
	foreach($fields_with_lengths as $fieldname => $maxlength ) {
		if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
	}


	if (!empty($errors)) {
		redirect_to("errors.html");
	}
	*/
?>

<?php
	$DiscrepType = mysql_prep($_POST['List1']);
	$DiscrepDetail = mysql_prep($_POST['List2']);
	$Airdate = $_POST['Airdate'];
	$Description = mysql_prep($_POST['Description']);
	$Resolution = mysql_prep($_POST['Resolution']);
	$OnAirVariance = mysql_prep($_POST['OnAirVariance']);
	$EquipID = mysql_prep($_POST['EquipID']);
	$EquipLoc = mysql_prep($_POST['EquipLoc']);
	$StartTime = array ($_POST['StartTime']);
	$EndTime = array ($_POST['EndTime']);
	$MaterialID = array ($_POST['MaterialID']);
	$Title = array ($_POST['Title']);
	$Row = array ($_POST['Row']);

	/*
	$INISatNSS806 = $_POST['INISatNSS806'];
	$LaFamilia = $_POST['LaFamilia'];
	$G15Analog = $_POST['G15Analog'];
	$G15Digital = $_POST['G15Digital'];
	$DirecTV = $_POST['DirecTV'];
	$DISH = $_POST['DISH'];
	$INSPhits = $_POST['INSPhits'];
	$INSPolym = $_POST['INSPolym'];
	$HalHDgal15 = $_POST['HalHDgal15'];
	$HalGal15 = $_POST['HalGal15'];
	$HalOlym = $_POST['HalOlym'];
	$HalHits = $_POST['HalHits'];
	*/
?>
<?php
	$query1 = "INSERT INTO tblonairactivity (
			DiscrepType, DiscrepDetail, Airdate, Description, Resolution, OnAirVariance, EquipID, EquipLoc
			) VALUES (
			'{$DiscrepType}', '{$DiscrepDetail}', '{$Airdate}', '{$Description}', '{$Resolution}', '{$OnAirVariance}', '{$EquipID}', '{$EquipLoc}'
			)";
		
//	$lastID = LAST_INSERT_ID()

	$pos = -1;
	foreach($Row as $index) {
	$pos++;

	$query2 = "INSERT INTO tblAffectedProg (
			tblOnAirActivityID, StartTime, EndTime, MaterialID, Title
	        ) VALUES (
	        LAST_INSERT_ID(), '{$StartTime[$pos]}', '{$EndTime[$pos]}', '{$MaterialID[$pos]}', '{$Title[$pos]}')";
	        } 
/*
	$query3 = "INSERT INTO tblsatellites (
				INISatNSS806, LaFamilia, G15Analog, G15Digital, DirecTV, DISH, INSPhits, INSPolym, HalHDgal15, HalGal15, HalOlym, HalHits
			) VALUES (
				{$INISatNSS806}, {$LaFamilia}, {$G15Analog}, {$G15Digital}, {$DirecTV}, {$DISH}, {$INSPhits}, {$INSPolym}, {$HalHDgal15}, {$HalGal15}, {$HalOlym}, {$HalHits}
			)";
*/	
	$result = FALSE;
	if (mysql_query('BEGIN')) {
	    if (mysql_query($query1) &&
	        mysql_query($query2))
	        $result = mysql_query('COMMIT'); // both queries looked OK, save
	    else
	        mysql_query('ROLLBACK'); // problems with queries, no changes.
	    }

	if ($result) {
		// Success!
		//redirect_to("success.html");
	echo "<pre>" . print_r($_POST,1) . "</pre>"; 
		
	} else {
		// Display error message.
		echo "<p>Record creation failed.</p>";
		echo "<p>" . mysql_error() . "</p>";
	}
?>

<?php mysql_close($connection); ?>

I am getting the following error:
error said:
Notice: Undefined index: Row in C:\wamp\ on line 41

Only one record is being added to the table tblAffectedProg and the data being posted is the word "Array".

Here is what is echoed from my form:

Array
(
[Airdate] => 2012-5-17
[List1] => Equipment issue
[List2] => Digibeta deck
[EquipLoc] => Master Control
[EquipID] => test
[Network_INI] => -1
[OnAirVariance] => -1
[txtStartTime] => 17:00:00
[txtEndTime] => 18:00:00
[txtMaterialID] => test3
[txtTitle] => test3
[StartTime] => Array
(
[0] => 15:00:00
[1] => 16:00:00
)

[EndTime] => Array
(
[0] => 16:00:00
[1] => 17:00:00
)

[MaterialID] => Array
(
[0] => test1
[1] => test2
)

[Title] => Array
(
[0] => test1
[1] => test2
)

[row] => Array
(
[0] => 1
[1] => 2
)

[Description] => test
[Resolution] => test
[SaveRecord] => Save Record
)

I feel like I am really close but I don't quite know what is wrong. Thanks sooo much for your help.

Ken
 
the error suggests that no field named Row was submitted in the POSTED information.
 
Agreed.

Going back to your Javascript it seems your element6's name is "row", lowercase "r", while you are trying to get Row. uppercase "r" from the POST array.

Again, output your POST array like shown above to see what is is you are actually getting. This is a basic debugging technique.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Nice catch! Thank you. I am still only getting one record inserted to my tblAffectedProg and the data for all fields is the string "Array". It seems that the query is pulling the variable types for StartTime, EndTime, MaterialID and Title, rather than the indexed data.

This is from the echo of my POST:

POST said:
[StartTime] => Array
(
[0] => 15:00:00
[1] => 16:00:00
)

[EndTime] => Array
(
[0] => 16:00:00
[1] => 17:00:00
)

[MaterialID] => Array
(
[0] => test1
[1] => test2
)

[Title] => Array
(
[0] => test1
[1] => test2
)
 
Update:

I was able to make it insert the actual values to the table (tblAffectedProg) by removing the "= array ()" classification when declaring my variables, as follows:

PHP:
$StartTime = $_POST['StartTime'];
	$EndTime = $_POST['EndTime'];
	$MaterialID = $_POST['MaterialID'];
	$Title = $_POST['Title'];
	$Row = $_POST['row'];

But there is still only one record being inserted. I guess some progress is better than none :)

Ken
 
I think I may have identified the problem. I suspect that this piece of the code after my queries may be what is causing it:

PHP:
$result = FALSE;
	if (mysql_query('BEGIN')) {
	    if (mysql_query($query1) &&
	        mysql_query($query2))
	        $result = mysql_query('COMMIT'); // both queries looked OK, save
	    else
	        mysql_query('ROLLBACK'); // problems with queries, no changes.
	    }

I think that the only $query2 that is being committed is the last iteration of the loop. Is there a way to make it so that all iterations of the loop get commited. I am not married to the above way of doing it, I just need it to work.

Thanks,

Ken
 
I just wanted to post w/ my working code. I didn't realize till just now what the mysql_query() function was doing. I thought the query was executed when you defined it as a variable. I have a working script now. Thank you all for your input to help me get this going :)

Best regards,

Ken

PHP:
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>

<?php
	$DiscrepType = mysql_prep($_POST['List1']);
	$DiscrepDetail = mysql_prep($_POST['List2']);
	$Airdate = $_POST['Airdate'];
	$Description = mysql_prep($_POST['Description']);
	$Resolution = mysql_prep($_POST['Resolution']);
	$OnAirVariance = mysql_prep($_POST['OnAirVariance']);
	$EquipID = mysql_prep($_POST['EquipID']);
	$EquipLoc = mysql_prep($_POST['EquipLoc']);
	$StartTime = $_POST['StartTime'];
	$EndTime = $_POST['EndTime'];
	$MaterialID = $_POST['MaterialID'];
	$Title = $_POST['Title'];
	$Row = $_POST['row'];

?>
<?php
	$query1 = "INSERT INTO tblonairactivity (
			DiscrepType, DiscrepDetail, Airdate, Description, Resolution, OnAirVariance, EquipID, EquipLoc
			) VALUES (
			'{$DiscrepType}', '{$DiscrepDetail}', '{$Airdate}', '{$Description}', '{$Resolution}', '{$OnAirVariance}', '{$EquipID}', '{$EquipLoc}'
			)";
	$result1=mysql_query($query1);

	$lastID = mysql_insert_id();
			
	$pos = -1;
	foreach($Row as $index) {
	$pos++;

	$query2 = "INSERT INTO tblAffectedProg (
			tblOnAirActivityID, StartTime, EndTime, MaterialID, Title
	        ) VALUES (
	        $lastID, '{$StartTime[$index]}', '{$EndTime[$index]}', '{$MaterialID[$index]}', '{$Title[$index]}')";
	
	$result2=mysql_query($query2);
	}
	if ($result1 && $result2) {
		// Success!
		//redirect_to("success.html");
		echo "<pre>" . print_r($_POST,1) . "</pre>"; 
		
	} else {
		// Display error message.
		echo "<p>Record creation failed.</p>";
		echo "<p>" . mysql_error() . "</p>";
	}
?>

<?php mysql_close($connection); ?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top