Login  |  Register
Middle East Directory  - Article Details
STATISTICS
  • Active Links: 407
  • Pending Links: 1
  • Todays Links: 4
  • Total Articles: 7
  • Total Categories: 18
  • Sub Categories: 5

super fast xml sitemap generator (from database)

Date Added: August 15, 2008 11:06:31 AM
Author: sameh
Category:
XML sites map are important for google seo
but a lot of old php scripts does not support xml maps to be created from the php script itself so this code will work with any php script that get the data from a mysql database
[PHP]<?php
mysql_connect("localhost", "DataBase-UserName", "database-password") or
    die("Could not connect: " . mysql_error());
mysql_select_db("DataBase-Name");//////////// <  
?>
<?php
 $sql = "SELECT  * FROM thread";
 $result = mysql_query($sql) 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($result)) {
 ?>
 <url>
 <loc>http://www.yoursite.com/?t=<?php echo $row['threadid']; ?></loc>
 <lastmod>2008-03-23T13:36:17+00:00</lastmod>
 <priority>0.50</priority>
 <changefreq>weekly</changefreq>
 </url>
 <?php } ?>
 </urlset>
[/PHP]
this code will generate XML sitemap directly from the database you just need to adjust the code according to your database and php script

[PHP] $sql = "SELECT  * FROM thread";[/PHP] thread is the mysql taple

[PHP]<?php echo $row['threadid']; ?>[/PHP] threadid is the item id
Ratings
You must be logged in to leave a rating.
Average rating: 10 (1 votes)
Comments

No Comments Yet.


You must be logged in to leave a Comment.
ARTICLES
www.professionalcolleges.org-Our parrent company
WORK AND STUDY IN CANADA WHICH LEADS TO LANDED & PERMANENT RESIDENT STATUS Apply now for January intake with work permit www.professionalcolleges.org
website total solutions
website online support team
Greater role of the credit card in students’ lives
College students often find themselves paying only the monthly minimum payment on each of their credit cards due to limited funds.
Gulf Greats: CANADIANS TRIUMPH IN DUBAI
SDI Canada, designs, constructs and install suites for diagnostic imaging equipment such as MRIs, CT scanners, X-ray machines and PET scanners.
Work and study in Canada
Work and study in canada apply for january intake now www.professionalcolleges.org