title: How to create multiple sitemaps with php mysql?
body: <p>I am trying to create multiple sitemaps for my website using php mysql. Here is what I have tried but its not working. I have video titles in database and unique_ids. What I am trying to do is. First I store titles and unique ids in variables than. I replace spaces with (-) and than i put unique id at the end of titles. and from there I get all the titles in one unique varible $titleSEO. which is url of video but for some reason my code is not working.</p>
  
  <pre><code>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 &gt; 50000){
      $i=$i++;
  }
  
  
      $cfile = 'sitemap_' . $i  . '.xml';
      $createfile = fopen($cfile, 'w');
  
      fwrite($createfile, "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n");
      fwrite($createfile, "&lt;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\"&gt;\n");
  
  
          $creat = "&lt;url&gt;\n";
          $creat .= "&lt;loc&gt;http://mimuz.com/" . $title . ".html&lt;/loc&gt;\n";
          $creat .= "&lt;priority&gt;1.00&lt;/priority&gt;\n";
          $creat .= "&lt;/url&gt;\n";
  
          fwrite($createfile, $creat);
  
      fclose($createfile);
  
  
  
  
  }
  </code></pre>