我对 PHP 还是很陌生,我从社区中学到了一些东西,但我还有很多东西要学,我希望你们能给我关于这个问题的建议。
我的问题是关于下拉菜单。我目前有一个下拉菜单,可以从表格中提取信息。信息显示我可以从下拉菜单中选择的成分。现在我希望能够使用这些成分在我的食谱表中搜索食谱,但我不知道该怎么做。
我的ingredients
表包含两个字段。
ingredient id
和 recipe id
我的recipe
表包含两个字段
recipe id
和recipe name
我recipeingredients
的复合键表有两个字段
recipe id
和ingredient id
我下面的 HTML 代码是下拉菜单
<form id="searchForm">
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="GET">
<h3> Search your recipe here </h3>
<fieldset>
Ingredient 1:<select name= "dropdown1" id = "drop1"/>
<?php
while ($line = mysql_fetch_array($result1, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['ingredientname'];?>"> <?php echo $line['ingredientname'];?> </option>
<?php
}
?>
</select>
Ingredient 2:<select name = "dropdown2" id = "drop2"/>
<?php
while ($line = mysql_fetch_array($result2, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['ingredientname'];?>"> <?php echo $line['ingredientname'];?> </option>
<?php
}
?>
<input type="submit" value="Go!" />
<input type="submit" value="Search" />
</form>
我有一种感觉,我可能需要加入,但就像我说的,我是新手,所以请温柔一点。