Combining two PHP variables for MySQL query

Jbzfnlwlab

New Member
I have a variable formvar that is incremented every time a user adds an additional field in an HTML form. This variable is posted to the PHP script for the purpose of looping through all of the added fields. I am trying to combine two variables in the MySQL query to match what is in my HTML form. I would like the MySQL query to go upc0, upc1, etc until the for loop terminates. \[code\]for($i=0;$i<=$_POST[formvar];$i++){mysql_select_db("bits", $con);$sql="INSERT INTO report (UPC, Quantity, Comment)VALUES ('$_POST[upc].$i','$_POST[quantity].$i','$_POST[comment].$i')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }else echo "Records added successfully";}\[/code\]Sorry if this code is bad, I am new to web programming.Thank you!
 
Back
Top