Create Dynamic Sitemap Using PHP with Mysql

Create Dynamic Sitemap Using PHP with Mysql

In this Post We Will Explain About is Create Dynamic Sitemap Using PHP with Mysql With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to SiteMap XML Dynamic SiteMap Generator using PHPExample

In this post we will show you Best way to implement Create Dynamic XML Sitemap & Rss Feed using PHP & MySQL, hear for xml – Creating dynamic sitemap with phpwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   Create JSON with json_encode and json_decode using PHP




Creating Dynamic XML Sitemaps using PHP Example

Sitemaps generally to be in XML data format, so that does not mean any all that We have to write simple XML source code for each page data manually. Let’s start to build a XML based sitemap together with simple PHP scripts.

<?php 

/* Creating Dynamic XML Sitemaps using PHP devloped by live24u.com*/
header("Content-Type: application/xml; charset=utf-8"); 
echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL; 
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' .PHP_EOL; 
 
function create_Elem($url) {
echo '<url>'.PHP_EOL; 
echo '<loc>'.$url.'</loc>'. PHP_EOL; 
echo '<changefreq>weekly</changefreq>'.PHP_EOL; 
echo '</url>'.PHP_EOL;
} 
 
create_Elem('http://www.live24u.com/services/default-text-generator/'); 
create_Elem('http://www.live24u.com/tests/livedata/'); 
create_Elem('http://www.live24u.com/tests/livedata/HTML/'); 
echo '</urlset>'; 
?>

What is an XML Sitemap

Almost all some information we need to know here site about Sitemaps is available at officel site like as a http://www.sitemaps.org.

Also Read :   Create Dynamic XML Sitemaps Using PHP MYSQL

How to submit Sitemap to search engines

Google:simple Google Webmaster search Tools
Bing: simple Bing Webmaster search Tools
Yandex:simple Yandex Webmaster search Tools
Baidu:simple china Baidu Webmaster search Tools

Dynamic Create Site Map using PHP

This is a simple script, written in simple PHP, that will create or generate a simple dynemic site map based on the folder or directory structure of the web-site. We can easily simple exclude files and/or some directories.

<?php
mysql_connect("localhost", "live DataBase-UserName", "live database-password") or
    die("your Could not connect: " . mysql_error());
mysql_select_db("live DataBase simple Name");
?>
<?php
 $sql_get = "SELECT  * FROM data_post";
 $data_result = mysql_query($sql_get) or die(mysql_error());
 header('Content-Type: application/xml');
 echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
 echo "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd\">";
 while($row = mysql_fetch_assoc($data_result)) {
 ?>
 <url>
 <loc>http://www.live24u.com/?t=<?php echo $row['livepost_id']; ?></loc>
 <lastmod>2008-03-23T13:36:17+00:00</lastmod>
 <priority>0.50</priority>
 <changefreq>weekly</changefreq>
 </url>
 <?php } ?>
 </urlset>





Example

Also Read :   Export data mysql table to csv file using PHP

I hope you have Got What is Create Dynamic XML Sitemap & Rss Feed using PHP & MySQL And how it works.I would Like to have FeadBack From My Blog(live24u.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(live24u.com) Are Most Always Welcome.