<?php include_once("include/main.inc.php");
$admin_res = getAdminDetails();
?>
<!DOCTYPE html>
<html lang="en" itemscope>

<head itemscope itemtype="">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
    <title><?=$admin_res['companyName'] ?> Market Area - We supply our products here </title>
    <meta name="description" content="Products of <?= $admin_res['companyName'] ?> are available in these locations. If you are from any of these locations & want to buy our products, Feel free to contact us." />
<meta name="keywords" content="<?= $admin_res['companyName'] ?> - Market Area" />
    <?php include "app_top.php"; ?>
</head>

<body itemscope itemtype="">
    <?php include "app_header.php"; ?>

    <!-- Heading Banner--->
    <section class="heading_banner" style="background-image: url(<?= theme_url ?>images/market-banner.jpg)">
        <div class="container">
            <div class="row">
                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-center">
                    <div class="cat_title">Market Area</div>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </section>

    <!-- Breadcrumb--->
    <section class="inner_breadcrumb hidden_xs">
        <div class="container">
            <div class="row">
                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <ul class="breadcrumb">
                        <li><a href="<?= site_url ?>" title="Home">Home</a></li>
                        <li class="active">Market Area</li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <section class="sitemap_page">
        <div class="container">
            <div class="market_area">
                <?php
                $sel_location_query = "select * from location_tbl where parentID = '0' and status ='Y' order by locationName asc";
                $res_location = $dbconn->query($sel_location_query);
                if($res_location->num_rows > 0) { ?>
                <h2 class="mt25">Market Area - <?= $admin_res['companyName']; ?></h2>
                <ul class="market-list">
                    <?php
                        while($locations = $res_location->fetch_assoc()){
                            $name_location = trim($locations['locationName']);
                            $href_location = str_ireplace(" ", "-", $name_location);
                    ?>
                    <li><a href="<?= site_url.'/'.strtolower($href_location); ?>/" title="<?= $name_location; ?>"><?= $name_location; ?></a></li>
                    <?php } ?>
                </ul>
                <?php } 
                $sel_location_query = "select * from location_tbl where parentID = '0' order by locationName asc";
                $res_location = $dbconn->query($sel_location_query);
                if($res_location->num_rows > 0) {
                    while($co_locations = $res_location->fetch_assoc()){
                        $coName_location = trim($co_locations['locationName']);
                        $sel_state_query = "select * from location_tbl where parentID = '".$co_locations['locationID']."' and status = 'Y' order by locationName asc"; 
                        $res_state_location = $dbconn->query($sel_state_query);
                        if($res_state_location->num_rows > 0){
                ?>
                <h2 class="mt25">States of <?= $coName_location; ?></h2>
                    <ul class="market-list">
                        <?php while($state_locations = $res_state_location->fetch_assoc()){
                            $state_name = trim($state_locations['locationName']);
                            $href_state = str_ireplace(" ", "-", $state_name);
                        ?>
                        <li><a href="<?= site_url.'/'.strtolower($href_state); ?>/" title="<?= $state_name; ?>"><?= $state_name; ?></a></li>
                        <?php } ?>
                    </ul>                            
                        
                <?php } } } 
                $sel_location_query = "select * from location_tbl where parentID = '0' order by locationName asc";
                $res_location = $dbconn->query($sel_location_query);
                if($res_location->num_rows > 0) {
                    while($co_locations = $res_location->fetch_assoc()){
                        
                ?>
                    <?php $sel_state_query = "select * from location_tbl where parentID = '".$co_locations['locationID']."' order by locationName asc"; 
                            $res_state_location = $dbconn->query($sel_state_query);
                            if($res_state_location->num_rows > 0){ 
                            while($state_location = $res_state_location->fetch_assoc()){
                                $state_name = trim($state_location['locationName']);
                                $sel_city_query = "Select * from location_tbl where parentID = '".$state_location['locationID']."' and status = 'Y' order by locationName asc";
                                $res_city = $dbconn->query($sel_city_query);
                                if($res_city->num_rows > 0){
                            ?>
                            <h3 class="mt25">Cities of <?= $state_name; ?></h3>
                            <ul class="market-list">
                                <?php while($city_location = $res_city->fetch_assoc()){ 
                                        $city_name = trim($city_location['locationName']);
                                        $city_href = str_ireplace(" ", "-", $city_name);
                                ?>
                                    <li><a href="<?= site_url.'/'.strtolower($city_href); ?>/" title="<?= $city_name; ?>"><?= $city_name; ?></a></li>
                                <?php } ?>
                                </ul>
                                <?php
                                } 
                            } 
                        }
                    } 
                } ?>
            </div>

        </div>
    </section>

    <?php include "app_footer.php"; ?>
    <?php include "app_bottom.php"; ?>
</body>

</html>