Hi everyone, please help me out on this if you can.
I have a site where a user can select multiple checkbox values, banana, apple, orange, strawberry and raspberry.
I would like the name of the Juice to be displayed if the fruit is contained in it. For example..if strawberry and raspberry was selected then Berry Juice would be outputted.
Here is the code I am using for the checkboxes.
<form action="result.php" method="POST" >
<input type="checkbox" name="ingredients[]" value="Banana">Banana<br>
<input type="checkbox" name="ingredients[]" value="Apple">Apple<br>
<input type="checkbox" name="ingredients[]" value="Orange">Orange<br>
<input type="checkbox" name="ingredients[]" value="Raspberry">Raspberry<br>
<input type="checkbox" name="ingredients[]" value="Strawberry">Strawberry<br>
</span><br />
<input type="submit" value="Submit" />
I only have two columns in my table..juice name and ingredients. I have multiple values in each row.
This is the way my table is set up.
Juice Name Ingredients
Berry Raspberry, Strawberry
Cider Apple, Banana
Here is my php code for result.php
<?PHP
$dbhost = "x";
$dbname = "x";
$dbuser = "x";
$dbpass = "x";
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT juicename FROM juice;
echo $query;
$apple = $_POST['apple'];
$banana = $_POST['banana'];
$orange = $_POST['orange'];
$raspberry = md5($_POST['raspberry']);
$strawberry = $_POST['strawberry'];
$query = "SELECT juicename FROM juice WHERE match (ingredients) against searchvalue
values ('$apple', '$banana', '$orange', '$raspberry', '$strawberry')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo $query
?>
Many thanks