0
データベースに行の配列を挿入しようとしていて、配列のすべての行に3つの別の行が含まれています。PHPを使用してphpmyadminに配列の配列を挿入するには
foreach($type as $a=>$b)
{
$sql="INSERT INTO `actual_regular` (`employee`, `sex`, `caste`, `family`, `local`, `worked_month`, `incash`, `total_salary`) VALUES ('$type[$a]', '$sex_actual[$a]', '$caste_actual[$a]', '$family_actual[$a]', '$employee_actual[$a]', '$worked_month[$a]', '$cash_actual[$a]', '$salary_actual[$a]');";
mysql_query($sql);
上記は、行の配列を挿入します。すべての行は、すべての行が3行以上が含まれている私は複数の行がテーブルactual_regular
に挿入する必要があるわけ
$insert = "INSERT INTO `more_regular` (`product_detail`, `unit`, `quantity`, `price`) VALUES ('$detail_product[0]', '$unit[0]', '$quantity[0]', '$price[0]');";
$insert = "INSERT INTO `more_regular` (`product_detail`, `unit`, `quantity`, `price`) VALUES ('$detail_product[1]', '$unit[1]', '$quantity[1]', '$price[1]');";
$insert = "INSERT INTO `more_regular` (`product_detail`, `unit`, `quantity`, `price`) VALUES ('$detail_product[2]', '$unit[2]', '$quantity[2]', '$price[2]');";
mysql_query($insert);
} // above foreach ends here
新しいテーブルに挿入される3行が含まれています。これらの3行はテーブルmore_regular
に挿入されます。
'foreachの($型と$ A => $ b)は'すでにあります上記のように 'foreach($ detail_product as $ x => $ y)'を使うと 'btは結果を得ることができません。 – yank
@Pupilそれぞれの値 '$ price [0] 'からセミコロンを削除します;' '<----' –
@Uchihaはいuは絶対に正しいです。 – yank