<?php 
include_once("include/main.inc.php"); 
$page_metatitle = "Market Area - ".$admin_res['companyName'];
$page_metakey = "Market Area - ".$admin_res['companyName'];
$page_metadesc = "Market Area - ".$admin_res['companyName'];
?>

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

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0;">

    <?php include "app_top.php"; ?>
</head>

<body>
    <?php include "app_header.php"; ?>


   
    <div class="heading_banner" style="background-image: url(<?=site_url;?>/designer/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">
                    <h1 class="cat_title">Market Area - <?=$admin_res['companyName'];?></h1>
                    <div class="clearfix"></div> 
                </div>
            </div>
        </div>
    </div>


    <div class="breadcrumbSection 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>
    </div>

    <section class="sitemap_page">
    <div class="container">
        <div class="wps_right market_area">

            <?php 
            $sql_loc = mysqli_query($GLOBALS['dbconn'], "SELECT locationName, parentID, locationID, loc_url FROM location_tbl WHERE parentID='0' AND status='Y' ORDER BY locationName ASC");

            if (mysqli_num_rows($sql_loc) > 1) {
                echo '<h2 class="mt25">Countries</h2>';
            } else {
                echo '<div class="mt25"></div>';
            }

            echo '<ul class="market-list">';
            while ($res_loc = mysqli_fetch_array($sql_loc)) { 
                $loc_url = $res_loc['loc_url'] ? $res_loc['loc_url'] : $res_loc['locationName']; ?>
                <li>
                    <a href="<?= site_url; ?>/<?php echo getValidFileName($loc_url); ?>/" title="<?php echo $res_loc['locationName']; ?>">
                        <?php echo $res_loc['locationName']; ?>
                    </a>
                </li>
            <?php } 
            echo '</ul>';
            ?>

            <h2 class="mt25">States of India</h2>
            <ul class="market-list">
            <?php
            $sql_locsss = mysqli_query($GLOBALS['dbconn'], "SELECT locationName, parentID, locationID, loc_url FROM location_tbl WHERE parentID='1' AND status='Y' ORDER BY locationName ASC");
            while ($res_locsss = mysqli_fetch_array($sql_locsss)) { 
                $loc_url1 = $res_locsss['loc_url'] ? $res_locsss['loc_url'] : $res_locsss['locationName']; ?>
                <li>
                    <a href="<?= site_url; ?>/<?php echo getValidFileName($loc_url1); ?>/" title="<?php echo $res_locsss['locationName']; ?>">
                        <?php echo $res_locsss['locationName']; ?>
                    </a>
                </li>
            <?php } ?>
            </ul>

            <?php
            // Fetch states again for cities (maybe optimize this later)
            $sql_loccc = mysqli_query($GLOBALS['dbconn'], "SELECT locationName, parentID, locationID, loc_url FROM location_tbl WHERE parentID='1' ORDER BY locationName ASC");
            while ($res_loccc = mysqli_fetch_array($sql_loccc)) {
                $locationID = $res_loccc['locationID'];
                $sql_loc1 = mysqli_query($GLOBALS['dbconn'], "SELECT locationName, parentID, locationID, loc_url FROM location_tbl WHERE parentID='$locationID' AND status='Y' ORDER BY locationName ASC");

                if (mysqli_num_rows($sql_loc1) > 0) {
                    echo '<h3 class="mt25">Cities of ' . $res_loccc['locationName'] . '</h3>';
                    echo '<ul class="market-list">';
                    while ($res_locfinal = mysqli_fetch_array($sql_loc1)) {
                        $loc_url2 = $res_locfinal['loc_url'] ? $res_locfinal['loc_url'] : $res_locfinal['locationName']; ?>
                        <li>
                            <a href="<?= site_url; ?>/<?php echo getValidFileName($loc_url2); ?>/" title="<?php echo $res_locfinal['locationName']; ?>">
                                <?php echo $res_locfinal['locationName']; ?>
                            </a>
                        </li>
                    <?php }
                    echo '</ul>';
                }
            }
            ?>

        </div>
    </div>
</section>


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

</html>