I have two dropdown one is category & other is product. I want to select value from category based on that i want to display value into product dropdown.
below is my code
<!-- <?php
// include('session.php');
?> -->
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('product_management');
$sql = "SELECT * FROM category";
$result = mysql_query($sql);
$sql1 = "SELECT * FROM category.c INNER JOIN products.p where WHERE category_id.p = '$id' ";
$result1 = mysql_query($sql1);
?>
<!DOCTYPE html>
<html>
<head>
<title>Product Page</title>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-12" style="margin-left: 30%;margin-top: 10%;">
<form role="form">
<div class="form-group">
<label>
Category
</label>
<select name='category_type' id="category_type">
<?php
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['category_id'] ."'>" . $row['category_type'] ."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label>
Products
</label>
<select id="products" name="products" required>
<option value=""> -- SELECT -- </option>
<?php
while ($row = mysql_fetch_array($result1)) {
echo "<option value='" . $row['products'] ."'>" . $row['products'] ."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label>
Price
</label>
<input type="text" id="price" name="price" required>
</div>
<div class="form-group">
<label>
Quantity
</label>
<select id="quantity" name="quantity" required>
<option value=""> -- SELECT -- </option>
</select>
</div>
<div class="form-group">
<label for="exampleInputFile">
Upload Image
</label>
<input id="exampleInputFile" type="file" />
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
How to achieve this? I want to Select one value from dropdown to display values in another dropdown value.