SEO

Make Google Sitemap - PHP

 this a simple Making  google Sitemap the php function
<?php
require_once(”opendb.php”);
function makeSitemap($fname){
 $str  = “”;
 $str .= “<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n”;
 $str .= “<urlset xmlns=\”http://www.sitemaps.org/schemas/sitemap/0.9\” xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\” xsi:schemaLocation=\”http://www.google.com/schemas/sitemap/0.84 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\”>\n“;
  $str .= “<url>”;
 $str .= “<loc>http://www.easemarry.com/</loc>”;
 $str .= “<lastmod>”.date(’Y-m-d\TH:m+08:00′).”</lastmod>”;
 $str .= “<changefreq>daily</changefreq>”;
 $str .= “<priority>1.00</priority>”;
 $str .= “</url>\r\n”;
 $str .= “<url>”;
 global $opendb;
 $sql=”SELECT url FROM table”;
 $query =$opendb->get_results($sql);
  if (count($query)>=1){
     foreach ($query as $list){
     $make_time=date(’Y-m-d\TH:m+08:00′);
     $str .= “<url>”;
     $str .= “<loc>”.$list->url.”</loc>”;
     $str .= “<lastmod>$make_time</lastmod>”;
     $str [...]