I have the following code to try and enter values into a database. The problem is I cant seem to find code for javascript itself to do this so am using the $.post to call myDb.php that has the coding therefor. This don't seem to work so need URGENT help please.
I either need a direct JAVASCRIPT way to do this or (and I know this is not PHP forum but maybe something wrong in my code) to please check all my coding.
I suspect that it might be because of it being inside the loop but not sure.
PLEASE HELP ME.

Code:
for (counter = 0; counter < this.items.length; counter++) { 
			tempItem = this.items[counter];
			j = counter + 1;
			totalCount2 ++;
			
			/*************************SETTING VARIABLES FOR THE DATABASE PHP *****************************/
			var custType = document.getElementById("f0").value;
			var custName = document.getElementById("f1").value;
			var custDbEmail = document.getElementById("f2").value;
			var custNumber = document.getElementById("f3").value;
			var custPostal1 = document.getElementById("f4").value;
			var custPostal2 = document.getElementById("f5").value;
			var custProvince = document.getElementById("province").value;
			var custCode = document.getElementById("f6").value;
			var itemDescription = tempItem.getValue('name');
			var itemQuantity = tempItem.getValue('quantity');
			var itemPrice = tempItem.getValue('price');
			/************* THIS CODING TO POST THE VARIABLES TO myDb.php ****************/
			var postingDb = $.post('myDb.php', {Type: custType,Name: custName,Email: custDbEmail,Number: custNumber,Postal1: custPostal1,Postal2: custPostal2,Province: custProvince,Code: custCode,Descript: itemDescription,Quant: itemQuantity,Pricee: itemPrice});
			
			/************* THIS CODE HAS NOTHING TO DO WITH THE DB ****************/
			eftStrn = "Item:\t " + tempItem.getValue('name') +
		              "\n\rQuantity:\t" + tempItem.getValue('quantity') +
		              "\n\rAmount:\tR" + tempItem.getValue('price') + " each"  + "\n\r--------------------------------" +
					  "\n\rItem Sub:\tR" + (tempItem.getValue('price')) * (tempItem.getValue('quantity')) + "\n\r--------------------------------\n\r";
		
			body_start = body_start + "\n\r" + eftStrn;
		}
MyDb.php code:
Code:
<?php
 
// This will display South African Time.
 date_default_timezone_set("Africa/Johannesburg");
 $tz = date_default_timezone_get();
 $date = date(DATE_RFC822);
  
  /****************************************DATABASE STUFF **********************************************/
  // I am setting all my variables to make it easier to change code at a later stage by just changing the variables
	$_host = "localhost";
	$_user = "hans";
	$_pass = "swanniebraai";
	$database = "cust_list";
	var $myconn;

	// Connect to the DB
			$conn= mysql_connect($_host, $_user, $_pass);
			if(!$conn) {
				die ("<strong>Cannot connect to the database</strong>");
			}
			else {
				$this->myconn = $conn;
				echo ("Connection established!<br /><br />");
			}

	// Select the DB
			mysql_select_db($this->database);
			if(mysql_error()) {
				die ("<strong>Cannot find the database " . $this->database . "</strong>");
			}
			else {
				echo ("Database selected!<br /><br />");
			}
			return $this->myconn;
			

	// Setting form field variable apon submit
			$type = $_POST['Type']; 
			$dateDb = $date;  
			$name = $_POST['Name'];
			$email = $_POST['Email'];
			$number = $_POST['Number'];
			$postal1 = $_POST['Postal1'];
			$postal2 = $_POST['Postal2'];
			$province = $_POST['Province'];   
			$code = $_POST['Code'];
			$descript = $_POST['Descript'];
			$quant = $_POST['Quante'];
			$price = $_POST['Price'];
	
	// To protect MySQL injection
	//		$gamename = stripslashes($gamename);
	//		$manufact = stripslashes($manufact);
	//		$price = stripslashes($price);
	//		$gamename = mysql_real_escape_string($gamename);
	//		$manufact = mysql_real_escape_string($manufact);
	//		$price = mysql_real_escape_string($price);
			
			
	// INSERT INTO THE DB
	$insert = "INSERT INTO orders VALUES ('', '$type', '$dateDb', '$name', '$email', '$numbert', '$postal1', '$postal2', '$province', '$code', '$descript', '$quant', '$price')";
	mysql_query($insert)
	
	mysql_close($this->myconn);
?>