I have a for with 2 dropdowns, 'category' and 'subcategory'
I'm trying to make my page that it shows records(products) in the table based on dropdown selection of the subcategoy dropdown.
So for example all records beloning to the subcat wheels have a subcat_id of 4. Sunbcategory table and products table both have a field subcat_id. This for the admin page so that i can remove, hide or show products.
Here my unworking code, the category and subcategory selects are filled fine............
<?php
include '../inc/categorydropdown.php';
?>
<p><label for="cat">Category</label>
<select name="cat" id="cat">
<?php echo $op;?>
</select><br />
<label for="subcat">Subcategory</label>
<select name="subcat" id="subcat"> </select></p>
<?php
include '../inc/connect.php';
if(isset($_POST['subcat'])){
$subcat = intval($_POST['subcat']);
$q = "SELECT * FROM products WHERE subcat_id = $subcat";
$result = $link->query($q);
if($result){
while($row=mysqli_fetch_array($result)){
echo "<input type='checkbox' name='remove[{$row['id']}]'>",
"<label for='Remove'><span class='text'>Remove</span></label>";
if ($row['status'] == 1){
echo"<input type='checkbox' name='hide[{$row['id']}]'>",
"<label for='hide'><span class='text'>Hide</span></label>";
}
if ($row['status'] == 2){
echo"<input type='checkbox' name='show[{$row['id']}]'>",
"<label for='show'><span class='text'>Show</span></label>";
}
echo "<br />",
"<img src='{$row['image']}' alt='{$row['name']}' />",
"<br />";
}
}