<?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 $sql = "SELECT * FROM thread"; PHP: thread is the mysql taple <?php echo $row['threadid']; ?> PHP: threadid is the item id for help with modwrite feel free to ask me
I will definitly use this code for my directory....we have PHP based web directory so it will definitly help improve page rank of my website.... Thank you so much for sharing this code with us...
really handy information. thank you so much i must try this instead of using sitemap generator wp plugins..
hey.. thanks for sharing . This script is working for my site. i have result on sitemap like this: at php code <loc>http://www.mysite.com/search/<?php echo $row['tag']; ?>.html</loc> and i get full resul for tag like this: <loc>http://www.mysite.com/search/1/lost wold.html</loc> <loc>http://www.mysite.com/search/1/my new story.html.html</loc> my question now, how to make the result to auto add - before and after word if the result have more than 1 word? e.g lost wold can change to lost-wold.html, my new story can change to my-new-story.html? hope can help me ...