<?php
//error_reporting(1);
$servername = "localhost";
$username = "mannucpa_user";
$password = "1qa2WS3ed";
$database = "mannucpa_website";

// Create connection
$con = new mysqli($servername, $username, $password, $database);

// Check connection
if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
}
$site_url ="https://www.mannubhai.com";
?>
<form method="POST">
    <input type="text" name="url_slug" ><br>
    <input type="submit" name="submit">
    <br>
    <a href='https://www.mannubhai.com/sitemap.php'>Reset</a>
</form>


<?php 
if(isset($_POST['submit'])){
    
    $url_slug = $_POST['url_slug'];
$file_text ='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
?>

<?php
//$pgqry = mysqli_query($con,"SELECT * FROM `landing_pages` WHERE `page_url` LIKE '%$url_slug%'");
$q = "SELECT * FROM `city_tb` where status ='1' order by city_name asc";
$sq = mysqli_query($con,$q);
//while($ct = mysqli_fetch_object($sq)){
//echo $ct->id;
//print_r($ct);

//$pgqry = mysqli_query($con,"SELECT category_manage.*,page_master_tb.*,city_tb.* FROM category_manage join  page_master_tb ON page_master_tb.category_id = category_manage.id  join city_tb on  page_master_tb.city_id = city_tb.id where page_master_tb.city_id = $ct->id  group by page_master_tb.category_id ");
while($pgres = mysqli_fetch_object($sq)){
//print_r($pgres);
$cq = "SELECT * FROM `city_tb` where id='$pgres->city_id'";
$csq = mysqli_query($con,$cq);
$cres = mysqli_fetch_object($csq);
$cityurl = $cres->city_url;

$file_text.= "
<url>
    <loc> 
        $site_url/$pgres->city_url/$url_slug
    </loc>
    <changefreq>weekly</changefreq>
    <priority>0.9</priority>
</url>\n";
 } 
 $file_text.='</urlset>';
 ?>



<?php 
/*$my_file = 'file.xml';
$handle = fopen($my_file, 'a') or die('Cannot open file:  '.$my_file);
$data = $file_text;
fwrite($handle, $data);
//$new_data = "\n".'New data line 2';
fwrite($handle, $new_data);

echo "<a href='https://www.rocareindia.com/file.xml' target='_blank'>Download</a>";*/

//}
echo $file_text;
}
?>