I have this code:
<html>
<body>
<form method="post" action="">
Category: <select name="category">
<option>Choose Category</option>
<?php
include("connect.php");
$select="SELECT * FROM category";
$result=mysqli_query($link,$select) or die (mysqli_error($link));
while($row=mysqli_fetch_array($result))
{
echo "<option value='$row[category]'>".$row['category'];
}
?>
</select>
<br>
Subcategory:<select name="category">
<?php
include("connect.php");
$category=@$_POST['category'];
if($category=="Friuts")
{
$select="SELECT * FROM subcategory WHERE $category='$category'";
$result=mysqli_query($link,$select) or die (mysqli_error($link));
while($row=mysqli_fetch_array($result))
{
echo "<option value='echo $row[subcategory]'>".$row['subcategory'];
}
}
?>
</select>
<br>
<input type="submit" value="Open" name="submit">
</form>
</body>
</html>
I have two tables, table one name category and table two name subcategory, I want two when I choice one item option from table category get data from table subcategory in the select option appear in the image below: