Sub Cat List get vanish when click on a sub cat name

A

Anonymous

Guest
Hi Guys, if anybody there to help me out in the issue below please:

I am learning PHP/PDO via project in youtube. by learning project I have created code below which is all fine but as soon as I click on a sub category, it shows products into center column but sub category list get vanish, I don't know what mistake I have done, I tried everything to redirect it to its own location i.e. into the left column but remain unsuccessful. it will be appreciated if someone help me in resolving the issue. code is here below:

function for sub cat list:
function list_all_subcat(){
include("includes/dbconn.php");
if(isset($_GET['cat_id'])){
$cat_id=$_GET['cat_id'];
$subcat_list=$conn->prepare("select * from sub_cat where cat_id='$cat_id'");
$subcat_list->setFetchMode(PDO:: FETCH_ASSOC);
$subcat_list->execute();

while($row_subcat_list=$subcat_list->fetch()):
echo "<li><a href='cat-detail.php?subcat_id=".$row_subcat_list['sub_cat_id']."'>".$row_subcat_list['sub_cat_name']."</a></li>";
endwhile;
}
}

function called into left column:
div id="bodyleft">
<div id="leftup">
<h2>Categories</h2>
<ul>
<?php echo list_all_cat(); ?>
</ul>
</div>
<div id="leftdown">
<h2>Sub Categories</h2>
<ul>
<?php echo list_all_subcat(); ?>
</ul>
</div>
</div>
cat-detail.php cpntains below code in body:

<div id="bodycontainer">
<?php
include('includes/bodyleft.php');
include('includes/bodycenter.php');
include('includes/bodyright.php');
?>
</div>
bodycenter contains below code in body:
<div>
<ul><?php echo cat_detail();?></ul><br clear='all'> //this will show details into center
<ul><?php echo subcat_detail();?></ul><br clear='all'>
</div>

Everything is working fine When I click on a Category in left column up, category list remain there and shows the related Sub Category which is OK

But when I click on a Sub Category into sub cat List then everything works fine except sub cat list which go went gone and I again need to click on category.

I remain failed to resolve this issue if anybody can help in this I will be thankful to him/her please.
 
Back
Top