Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > PHP: Базы Данных > Группировка или типа того


Автор: newnoob 19.7.2007, 01:16
Вообщем есть такой код:

Код

 case "Calendar":
             $sitemap .= "<url><loc>$homeurl/index.php?name=News</loc><changefreq>$module_update[$title]</changefreq><priority>$module_prioritet[$title]</priority></url>";
             $calendar++;
             $sum++;
             $result2 = $db->sql_query("SELECT sid, time FROM ".$prefix."_stories WHERE sid AND status='1' AND time <= now() GROUP BY `time`");
             while (list($sid, $time) = $db->sql_fetchrow($result2)) {
                 $calendar++;
                 $sum++;
                 if (is_int($sum/50000)) {$new_map = "[50000]";}else{$new_map="";}
                 $lastmod = str_replace(" ", "T", "$time")."+03:00";
                 if (preg_match("|([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})|i", $time, $regs)) {
                     $time = "$regs[3].$regs[2].$regs[1]";
                 }
                 $sitemap .= "<url><loc>$homeurl/news-$time.html</loc><lastmod>$lastmod</lastmod><changefreq>weekly</changefreq><priority>$module_prioritet[$title]</priority></url>$new_map";
             }
             $url .= "<tr class=\"bgcolor1\"><td>Calendar:</td><td align=\"center\">$calendar</td></tr>";
             break;


Сейчас вывод идет такой:

Код

<url> 
<loc>http://host.net/news-11.07.2007.html</loc> 
<lastmod>2007-02-28T01:02:00+03:00</lastmod> 
<changefreq>weekly</changefreq> 
<priority /> 
</url> 

<url> 
<loc>http://host.net/news-11.07.2007.html</loc> 
<lastmod>2007-02-28T01:02:00+03:00</lastmod> 
<changefreq>weekly</changefreq> 
<priority /> 
</url>


Как видите ничего заурядного обычная выборка для Google Sitemap, но! Сейчас у меня выводится 1 дата по несколько раз что ни есть гуд, нужно сделать что то типа:

Код

<url> 
<loc>http://host.net/news-11.07.2007.html</loc> 
<lastmod>2007-02-28T01:02:00+03:00</lastmod> 
<changefreq>weekly</changefreq> 
<priority /> 
</url> 

<url> 
<loc>http://host.net/news-12.07.2007.html</loc> 
<lastmod>2007-02-28T01:02:00+03:00</lastmod> 
<changefreq>weekly</changefreq> 
<priority /> 
</url>

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)