$register_data2 = array(
'first_name' => $_POST["fname"][$j],
'last_name' => $_POST["lname"][$j],
'passport' => $_POST["passport"][$j],
'visa' => $_POST["visa"][$j],
'address1' => $_POST["address1"][$j],
'address2' => $_POST["address2"][$j],
'email' => $_POST["email"][$j],
'contact' => $_POST["contact"][$j],
'pin' => $_POST["pin"][$j],
'leaving_from' => $pieces[0],
'going_to' => $pieces[2],
'depart_date' => $pieces[7],
'depart_time' => $pieces[12],
'arrival_time' => $pieces[17],
'grand_fare' => $pieces[22],
'returning_from' => $pieces1[0],
'returning_to' => $pieces1[2],
'returning_date' => $pieces1[7],
'returning_time' => $pieces1[11],
'reaching_time' => $pieces1[16],
'fare' => $pieces1[21]
);
如何将这个数据数组插入到wampserver中phpadmin的mysql数据库中请帮忙。
答案 0 :(得分:-1)
我想这个例子应该按照你的数组工作。
$register_data2 = array(
'first_name' => 1,
'last_name' => 2,
'passport' => 3,
'visa' => 4,
'address1' => 5,
'address2' => 6,
'email' => 7,
'contact' => 8,
'pin' => 9,
'leaving_from' => 1
);
$query = "INSERT INTO TABLE_NAME SET ";
foreach($register_data2 as $column_name => $value){
$query .= $column_name . " = '" . $value . "' , ";
}
echo $final_query = rtrim($query,", ");