<?php
include('include/main.inc.php');
$web_det_query = "Select * from admin_details where slno = '1'";
$res_web = $dbconn->query($web_det_query);
$web_details = $res_web->fetch_assoc();
$page_metatitle = $web_details['companyName'].' - Market Area';
$page_metadesc = $web_details['companyName'].' - Market Area';
$page_metakey = $web_details['companyName'].' - Market Area';

?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?= $page_metatitle; ?></title>
    <meta name="description" content="<?= $page_metadesc; ?>">
    <meta name="keywords" content="<?= $page_metakey; ?>" >
    <?php include "app_top.php"; ?>
</head>
<body>
    <?php include "app_header.php"; ?>

    <section class="pageBanner" style="background-image:url('<?= site_url; ?>/designer/images/about-banner.jpg')">
        <div class="container">
            <div class="pagebannerWrap">
                <h1 class="pagebanner_heading">Market Area</h1>
            </div>
        </div>
    </section>

        <!-- Quote Box -->
    <section class="w-p-s-home-feture">
        <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">
                    <div>
                        <div class="page_breadcrumb">
                            <ul>
                                <li><a href="<?= site_url; ?>" title="Home">Home</a></li>
                                <li>/</li>
                                <li>Market Area</li>
                            </ul>
                        </div>
                    </div>
                </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 - <?= $web_details['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){
                ?>
                <h3 class="mt25">States of <?= $coName_location; ?></h3>
                    <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>

    <div class="clear"></div>

    <?php include "app_testimonials.php"; ?>
    <?php include "app_faq.php"; ?>
    <?php include "app_clients.php"; ?>
    <?php include "app_footer.php"; ?>
    <?php include "app_bottom.php"; ?>
</body>
</html>