can anyone let me know what the wrong thing here as i am not able to add subcategories to category
<div class="col-lg-4 mx-md-auto paper-card"> <?php
if ( isset( $_POST[ 'submit' ] ) ) {
if ( empty( $_POST[ 'subcat' ] ) ) {
echo '<span style="color: red;"> Please Fill in the Category Name</span> ';
} else {
$subcat =clean($_POST[ 'subcat' ]);
$query = "insert into subcategory values ('','$_POST[cat]','$subcat')";
$result = mysqli_query( $con, $query );
if ( $result ) {
echo '<span style="color: green;">Category Added Successfully</span>';
} else {
echo ' Please Check Your Query ';
}
}
}
?> <form method="post" action=""> <div class="form-group"> <lable>Sub Category Name</lable> <input type="text" class="form-control" name="subcat"/> </div> <div class="form-group"> <lable>Select Category</lable> <select class="form_control" name="cat"> <?php
$query="select * from category";
$sql=mysqli_query($con,$query);
if(mysqli_num_rows($sql)>0){
while($row=mysqli_fetch_assoc($sql)){
?> <option value="<?php echo $row['cid']; ?>"> <?php echo $row['catname']; ?> </option> <?php
}
}
?> </select> </div> <div class="form-group"> <button class="btn btn-primary" name="submit">Submit</button> </div> </form> </div> </div></div>
<div class="col-lg-4 mx-md-auto paper-card"> <?php
if ( isset( $_POST[ 'submit' ] ) ) {
if ( empty( $_POST[ 'subcat' ] ) ) {
echo '<span style="color: red;"> Please Fill in the Category Name</span> ';
} else {
$subcat =clean($_POST[ 'subcat' ]);
$query = "insert into subcategory values ('','$_POST[cat]','$subcat')";
$result = mysqli_query( $con, $query );
if ( $result ) {
echo '<span style="color: green;">Category Added Successfully</span>';
} else {
echo ' Please Check Your Query ';
}
}
}
?> <form method="post" action=""> <div class="form-group"> <lable>Sub Category Name</lable> <input type="text" class="form-control" name="subcat"/> </div> <div class="form-group"> <lable>Select Category</lable> <select class="form_control" name="cat"> <?php
$query="select * from category";
$sql=mysqli_query($con,$query);
if(mysqli_num_rows($sql)>0){
while($row=mysqli_fetch_assoc($sql)){
?> <option value="<?php echo $row['cid']; ?>"> <?php echo $row['catname']; ?> </option> <?php
}
}
?> </select> </div> <div class="form-group"> <button class="btn btn-primary" name="submit">Submit</button> </div> </form> </div> </div></div>