データベースにレシピを追加するスクリプトを作成しています。私の add_recipe フォームでは、ユーザーが好きなだけ材料を追加できるオプションを提供したいと考えています。
次のコードは、これまで試したことがないため、テスト目的で思いついたものです。
<?php
$ingredient = '(another ingredient)';
$num_ingredients = $_REQUEST['select'];
?>
<html>
<form name="form1" method="post" action="onchange.php">
<select name="select" onchange="javascript: document.form1.submit();">
<option value=1>Add 1 Ingredient</option>
<option value=2>Add 2 Ingredients</option>
<option value=3>Add 3 Ingredients</option>
</select>
</form>
</body>
</html>
<?php
while ($num_ingredients <= 3) {
$num_ingredients++;
echo $ingredient;
echo '<br />';
}
?>
問題は...私のコードです、笑。例えば...
オプション値=1 戻り値:
(another ingredient)
(another ingredient)
オプション値=3 戻り値:
(another ingredient)
誰かが私を正しい方向に導くことができますか? どんな助けでも大歓迎です 8)