我正在尝试使用php mysql为我的网站创建多个站点地图。这是我尝试过但它不起作用。我在数据库和unique_ids中有视频标题。我想做的是。首先,我将变量中的标题和唯一ID存储起来。我用( - )替换空格,而不是在标题末尾添加唯一ID。从那里我获得了一个独特的varible $ titleSEO中的所有标题。这是视频的网址,但出于某种原因,我的代码无效。
require('db.php');
$query = "SELECT * FROM pm_videos";
$result=mysql_query($query);
//whle loop
while ($row = mysql_fetch_array($result)){
$title=$row['video_title'];
$unique=$row['unique_id'];
$title2= strtolower(str_replace(array(' ', ' '), '-', preg_replace('/[^a-zA-Z0-9 s]/', '', trim($title))));
$titleSEO= "$title2-$unique";
$titleSEO = array_chunk($titleSEO, 50000);
$maxlinksinsitemap = 50000;
$numbersofsitemap = ceil($count_array / $maxlinksinsitemap);
$i = 1;
if ($maxlinksinsitemap > 50000){
$i=$i++;
}
$cfile = 'sitemap_' . $i . '.xml';
$createfile = fopen($cfile, 'w');
fwrite($createfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
fwrite($createfile, "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n");
fwrite($createfile, "xmlns:image=\"http://www.sitemaps.org/schemas/sitemap-image/1.1\"\n");
fwrite($createfile, "xmlns:video=\"http://www.sitemaps.org/schemas/sitemap-video/1.1\">\n");
$creat = "<url>\n";
$creat .= "<loc>http://mimuz.com/" . $title . ".html</loc>\n";
$creat .= "<priority>1.00</priority>\n";
$creat .= "</url>\n";
fwrite($createfile, $creat);
fclose($createfile);
}