<?php require('header.php');?>

<section class="top-category section-padding">
         <div class="container">
             <div class="row">
                 <div class="col-md-12">
                     <h3 class="text-center pb-1">Shop By Category</h3>
                 </div>
             </div>
          </div>
</section>

<section>
         <div class="container">
            <div class="row">
                <?php
					$statement = $pdo->prepare("SELECT * FROM tbl_mid_category");
					$statement->execute();
					$result = $statement->fetchAll(PDO::FETCH_ASSOC);
					foreach ($result as $row1) {
						?>
					<div class="col-md-6">			
                        <div class="item2" onclick="$('#Display_id_<?php echo $row1['mcat_id'];?>').toggle();$(this).toggleClass('mycolor');">
                                <div class="category-item2">
                                    <div class="row">
                                    <div class="col-md-4  col-sm-4 col-4 "><img class="img-fluid" src="assets/uploads/<?php echo $row1['pic']; ?>" alt=""></div>
                                    <div class="col-md-6  col-sm-6 col-6 ">
                                        <div class="content">
                                            <span> <?php echo $row1['mcat_name']; ?></span>
                                            <p class="text2">
                                                <?php
            										$statement = $pdo->prepare("SELECT * FROM tbl_end_category WHERE mcat_id=?");
                                                    $statement->execute(array($row1['mcat_id']));
                                                    $result2 = $statement->fetchAll(PDO::FETCH_ASSOC);
                                                    foreach ($result2 as $row2) {
            											?>
            											<?php echo $row2['ecat_name']; ?>,
                                                	<?php
            										}
            										?>
                                            </p>
                                    </div></div>
                                    <div class="col-md-2 col-sm-2 col-2 "><div class="icon"><i class="mdi mdi-chevron-right"></i></div></div>
                                    </div>
                                </div>
                                <div class="p-10" id="Display_id_<?php echo $row1['mcat_id'];?>" style="display:none;">
                                    <div class="row" >
                                    <?php
            										$statement = $pdo->prepare("SELECT * FROM tbl_end_category WHERE mcat_id=?");
                                                    $statement->execute(array($row1['mcat_id']));
                                                    $result2 = $statement->fetchAll(PDO::FETCH_ASSOC);
                                                    foreach ($result2 as $row2) {
            											?>
                                    <div class="col-md-4 no-padding col-sm-4 col-4 text-center">
                                        <a href="product_special.php?id=<?php echo $row2['ecat_id']; ?>&type=end-category">
                                        <div class="category-item3">
                                            <img class="img-fluid" src="assets/uploads/<?php echo $row1['pic']; ?>" alt=""><br><?php echo $row2['ecat_name']; ?>
                                        </div>
                                        </a>
                                    </div>
                                                	<?php
            										}
            										?>
                                </div>
                                </div>
                                    
                        </div>
                    </div>
                    <div class="col-md-12"><br></div>
				<?php
					}
				?>
                
                
                </div>
             </div>
      </section>

<?php require('footer.php');?>