When I select a category it shows me a new error. I just need to echo the cupcake name and price of the selected category and if possible I want to add another dropdown button with taste. For example, if someone is looking for a birthday cupcakes will vanilla taste all birthday cupcakes with vanilla taste will be shown with their prices.
<html>
<body>
<?php
$server="localhost";
$username="root";
$password="";
$connect_mysql=mysql_connect($server,$username,$password) or die ("Connection Failed!");
$mysql_db=mysql_select_db("wordpress",$connect_mysql) or die ("Could not Connect to Database");
$query = "SELECT * FROM category ";
$result=mysql_query($query) or die("Query Failed : ".mysql_error());
$i=0;
while($rows=mysql_fetch_array($result))
{
$roll[$i]=$rows['name_category'];
$i++;
}
$total_elmt=count($roll);
?>
<form method="POST" action="">
Select cupcake_category : <select name="sel">
<option>Select</option>
<?php
for($j=0;$j<$total_elmt;$j++)
{
?><option><?php
echo $roll[$j];
?></option><?php
}
?>
</select>
<input name="submit" type="submit" value="Search"/><br />
</form>
<?php
if(isset($_POST['submit']))
{
$value=$_POST['sel'];
$query2 = "SELECT * FROM cupcakes, category, taste WHERE
cupcakes.cupcake_id = category.id_category AND
category.id_category = taste.id_taste AND
category.cupcake_id = taste.cupcake_id";
$result2=mysql_query($query2) or die("Query Failed : ".mysql_error());
while($row=mysql_fetch_array($result2))
{
echo "cupcake name: ".$row['cupcake_name']."<br/>";
echo "price: ".$row['cupcake_price']."<br/>";
}
mysql_close($connect_mysql);
}
?>