I’m fairly new to search engine optimization. But, I’ve heard that sitemaps can drastically improve SEO. I know that the sitemap file has to be in xml format. But, the content of my site is very dynamic. That being said, I need to query the DB to find out how the content has changed as time goes on. My code is as follows:
<?php
require_once("functions.php");
connect();
// Query the DB to get the past season MLB teams
$query = mysql_query("SELECT * FROM past_season_team_articles") or die(mysql_error());
$count = mysql_num_rows($query);
$i = 0;
while($row = mysql_fetch_assoc($query))
{
$team[$i] = $row['team'];
$year[$i] = $row['year'];
$i++;
}
?>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
// Loop thru the array and echo out the MLB teams
for($i=0;$i<$count;$i++)
{
?>
<url>
<loc>http://www.sportannica.com/teams.php?team=<?php echo $team[$i]; ?>&year=<? php echo $year[$i]; ?></loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<?php
}
?>
</urlset>
I use .htaccess (both under Apache and under IIS using helicon) to map requests to sitemap.xml to sitemap.php which returns a ‘live’ sitemap.
Just had a quick look at your code but that looks about right, you just need to map the rewrite.