I have a script as below. There are some values from $_POST to be inserted to database. But it is not working. Need your help.
<?
$field = array(Priority_Rank, Attending_Period, Priority_Point_Low, Priority_Point_High, Other_Consideration);
$fields = implode(',', $field);
$fieldpost = array();
for ($i=0; $i<count($field); $i++) {
$fieldpost[] = $_POST[$i]; }
$fieldposts = implode (',', $fieldpost);
$query1 = "INSERT INTO $maindb ($mainID, $fields) VALUES ('$seq',$fieldposts)";
mysql_query($query1); ?>
I found out that the problem is in VALUES(...,$fieldposts), because if I change the query become the below, it is working perfectly.
$query1 = "INSERT INTO $maindb ($mainID, $fields) VALUES ('$seq','$_POST[0]','$_POST[1]','$_POST[2]','$_POST[3]','$_POST[4]')";
But since this query will also be used by other script that have different quantity of $_POST, I really need them to be looped in this file.
Note: $field is located in the other file.
<?
or you are asking fro troubles – Marcin Orlowski Dec 29 '13 at 12:01