- <?php
- header("Content-Type: application/xml; charset=utf-8");
- echo '<?xml version="1.0" encoding="UTF-8" ?>' . PHP_EOL;
- ?>
- <?php echo'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
- ?>
- <?php
- $conn=mysqli_connect("localhost","Username","Password","Database");
- ?>
- <?php
- $perpage = 4999;
- if(isset($_GET["page"])){
- $page = intval($_GET["page"]);
- }
- else {
- $page = 1;
- }
- $calc = $perpage * $page;
- $start = $calc - $perpage;
- $result = mysqli_query($conn, "select * from code Limit $start, $perpage");
- $rows = mysqli_num_rows($result);
- if($rows){
- $i = 0;
- while($post = mysqli_fetch_assoc($result)) {
- $stite=$post['title'];
- $stitle=strtolower("$stite");
- $stitle=str_replace(" ","-","$stitle");
- $stitle=str_replace("<","","$stitle");
- $stitle=str_replace(">","","$stitle");
- $stitle=str_replace("&","","$stitle");
- ?>
- <url><loc>https://yourdomain.com/slug/<?php echo $post["id"]; ?>-<?php echo $stitle; ?></loc></url>
- <?php
- }
- }
- ?>
- </urlset>