$insert_additional_info=sprintf("INSERT INTO tbl_additional_info (productid,size_d,size_d1,bags,cartons,retail_price,sales_price,wholesale_price) VALUES (%s, %s,%s, %s,%s,%s,%s,%s)",
GetSQLValueString($product_id, "int"),
GetSQLValueString($size_d, "int"),
GetSQLValueString($size_d1, "int"),
GetSQLValueString($bags, "int"),
GetSQLValueString($cartons, "int"),
GetSQLValueString($retail_price, "int"),
GetSQLValueString($sales_price, "int"),
GetSQLValueString($wholesale_price, "int"));
Instead of INSERTING like above, is there a way that I can use loop inside the VALUES()?
The reason is , my output or value to be inserted generated by looping like this.
if( isset($_POST['submit']) )
{
$_SESSION['myInputs_all'] = array($_POST["myInputs_d"],$_POST["myInputs_d1"],$_POST["myInputs_bags"],$_POST["myInputs_carton"],$_POST["myInputs_retail"],$_POST["myInputs_sales"],$_POST["myInputs_wholesale"]);
$counter = count( $_POST['myInputs_d']);
$column_array=array('productid,size_d,size_d1,bags,cartons');
for( $c = 0; $c < $counter; $c++ )
{
foreach( $myInputs_all as $all_inputs=>$value )
{
//This is the output
echo $value[$c];
}
}
}
Now, how do I insert echo $value[$c]; inside the VALUES for the INSERT QUERY?
I tried something like below but it says Query is empty. But this is how I want to solve it.
$insert_additional_info="INSERT INTO tbl_additional_info (productid,size_d,size_d1,bags,cartons) VALUES(";
$counter = count( $_POST['myInputs_d']);
for( $c = 0; $c < $counter; $c++ )
{
foreach( $myInputs_all as $all_inputs=>$value )
{
$insert_additional_info.=$value[$c];
$insert_additional_info.=")";
}
}