While genrating sitemap using php and mysql i am tottaly stuck with the errors in this, my requirement was to gerante multiple files sitmaps with the sitemap index if urls are greater than 5000 but this code i followed from a site totaly stucks me with errors please help me in this regards will be thankful to you mycode is here
<?php // Table Names
include("config.php");
$buffer = array();
$tables = array( 'tblusers', 'tblshares', 'tblreviews');
$custom_pre = array( 'users/', 'shares/', 'reviews/');
$pirorities = array( '0.8', '0.9', '1.0');
// Iterate over $tables
foreach($tables as $table and $custom_pre as $custom_pres and $pirorities as $piroritie)
{
// Build Query
$query = "SELECT `seo_url`, `added` FROM $table" .
"ORDER BY added DESC";
// Get Result
$result = mysql_query( $query );
// Iterate over Result
while( $row = mysql_fetch_array($result) )
{
// Chop up the Date
$date = substr($row['added'],0,4) . '-' .
substr($row['added'],5,2) . '-' .
substr($row['added'],8,2);
// Add page details to $buffer
$buffer[] = '<url>' .
'<loc>' . $site_baseurl . $custom_pres . $row['seo_url'] . '</loc>' .
'<lastmod>' . $date . '</lastmod>' .
'<changefreq>daily</changefreq>' .
'<priority>' . $piroritie . '</priority>' .
'</url>';
}
// Free MySQLi Result
$result->close();
}
// Output the Buffer to view. Make sure it looks good.
echo implode( "\r\n", $buffer );
// Remove the echo above and uncomment below if it looks good.
// if( ( $xml = fopen( 'sitemap.xml', "w" ) ) !== FALSE )
// {
// fwrite( $xml, implode( "\r\n", $buffer ) );
// }
?>