I am a little new to MySQL and PHP please help me.. I am try to do a web application where users select an ingredient (e.g..chicken) and it will show 11 recipes(I limited my recipes to 11) related to the selected ingredient.. It's working perfectly.. but I want to change it to check box so that users can select multiple ingredients (e.g.. chicken, carrot, butter).. I have no idea how to do it! Please help.. I have my database ready with all the recipes sorted out according to the Ingredient.
here is my code for the one Ingredient..
<div class="maindiv">
<div class="divA">
<div class="title">
</div>
<div class="divB">
<div class="divD">
<p>Click On Menu</p>
<?php
$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("SBI", $connection);
$query = mysql_query("select * from recipes", $connection);
while ($row = mysql_fetch_array($query)) {
echo "<b><a href=\"CookWhatLahSBIBefore.php?id={$row['id']}\">
{$row['name']}</a></b>";
}
?>
</div>
<?php
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query1 = mysql_query("select * from recipes where id=$id", $connection);
while ( $row1 = mysql_fetch_array($query1)) {
?>
<div class="form">
<h2>---You can cook..---</h2>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename1']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients1']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe1']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename2']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients2']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe2']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename3']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients3']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe3']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename4']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients4']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe4']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename5']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients5']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe5']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename6']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients6']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe6']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename7']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients7']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe7']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename8']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients8']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe8']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename9']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Ingredients:</span> <?php echo $row1['ingredients9']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe9']; ?><br><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Name:</span> <?php echo $row1['recipename10']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;"> Ingredients:</span> <?php echo $row1['ingredients10']; ?><br><br>
<span style="color: #0c0f44; font-size: 15pt;text-decoration:underline;">Recipe:</span> <?php echo $row1['recipe10']; ?><br><br><br>
</div>
<?php
}
}
?>
</div>
</div>
</div>