Double POST to MySQL

I have a Form with 2 Parts, the first being a standard form and the second part is in a multi-line table.
The issue is that it duplicates the first part into a second line.
Like This:

Entry | Entry | Entry | Entry | Entry | Entry | Entry | Entry | Entry | Entry | Entry |
Entry | Entry | Entry | Entry | Entry |

Here is the Code:

for($i=1;$i<=$_POST["hdnLine"];$i++)
{
	if($_POST["company"] != "")
	{
		$strSQL = "INSERT INTO customer ";
		$strSQL .="(company,companyaddress,contact,contacttitle,contactphone,contactmobile,contactemail,typeofunit,unitdescription,manufacturer,model,serial,yearbuilt,cooling,refrigerationtype,inputpower,bthrefrigeration,chiileroiltype,chiileroilcapacity) ";
		$strSQL .="VALUES ";
		$strSQL .="( '".$_POST["company"]."','".$_POST["companyaddress"]."', ";
		$strSQL .="'".$_POST["contact"]."' ";
		$strSQL .=",'".$_POST["contacttitle"]."','".$_POST["contactphone"]."', ";
		$strSQL .="'".$_POST["contactmobile"]."' ";
		$strSQL .=",'".$_POST["contactemail"]."','".$_POST["txttypeofunit$i"]."', ";
		$strSQL .="'".$_POST["txtunitdescription$i"]."' ";
		$strSQL .=",'".$_POST["txtmanufacturer$i"]."','".$_POST["txtmodel$i"]."',";
		$strSQL .="'".$_POST["txtserial$i"]."' ";
		$strSQL .=",'".$_POST["txtyearbuilt$i"]."','".$_POST["txtcooling$i"]."',";
		$strSQL .="'".$_POST["txtrefrigerationtype$i"]."' ";
		$strSQL .=",'".$_POST["txtinputpower$i"]."','".$_POST["txtbthrefrigeration$i"]."',";
		$strSQL .="'".$_POST["txtchiileroiltype$i"]."' ";
		$strSQL .=",'".$_POST["txtchiileroilcapacity$i"]."') ";
		$objQuery = mysql_query($strSQL);

echo out the query before its run so you can see what the sql server is seeing

So before $objQuery, add echo $strSQL."
";. I have a feelings its because you’re doing the query inside of a loop.

Sponsor our Newsletter | Privacy Policy | Terms of Service