一部の製品では、PHPで注文ページを開発しています。ユーザーは複数のタイプの製品を選択できる必要があるため、HTMLフォームにチェックボックスが必要です。HTMLフォーム(チェックボックス)から複数の「値」を転記できますか?
"name"属性でチェックボックスの配列を設定しました。
私の問題は、ユーザーが選択した内容を確認ページに表示したいので、これらのチェックボックスの「価値」が最終的に製品名と製品価格を返すことです。私は一つの値だけで立ち往生するつもりだ伝えることができますので、私はこれを回避しようとしてきた限り:
<?php
//variables for the array and the count
$parray = $_POST['product'];
$pcount = count($parray);
//arrays for each product's information; i've only listed one for simplicity
$br = array("Big Red", 575);
/*The idea for this was for each product ordered to add a line giving the product information and display it. When the $key variable is assigned, it is stored simply as a string, and not an array (yielding [0] as the first letter of the string and [1] as the second), which I expected, but my general idea is to somehow use $key to reference the above product information array, so that it can be displayed here*/
if (!empty($parray))
{
for ($i=0; $i < $pcount; $i++)
{
$key = $parray[i];
echo "<tr><td height='40'></td><td>" . $key[0] . "</td><td>" . $key[1] . "</td></tr>";
}
}
?>
それがあるかのように私の$キー変数は、実際に行動するためにとにかくあり配列の名前は?に設定されていますか? そうでない場合は、これを行うには良い方法がありますか?
あなたのHTMLは何に見えますか? – PeeHaa