本帖最后由 sslook 于 2012-08-10 17:37:17 编辑

解决方案 »

  1.   

    while($row = mysql_fetch_array($result))
    {    $data_array['loc']="http://zufang.sslook.com/sh/$ran/$row[0]";
        $data_array['priority']='1.0';
        $data_array['lastmod']='2012-12-12';
        $data_array['changefreq']='weekly';
        }
    这个while再次循环时,数组值data_array又被覆盖了,所以最终就一个值了,添加flag
    改为以下,都是hhh什么意思,数据库里东西吗,发出来看一下$i= 0;
    while($row = mysql_fetch_array($result))
    {    $data_array[$i]['loc']="http://zufang.sslook.com/sh/$ran/$row[0]";
        $data_array[$i]['priority']='1.0';
        $data_array[$i]['lastmod']='2012-12-12';//这些都被你定死了
        $data_array[$i]['changefreq']='weekly';
        ++$i;
        }
      

  2.   

    现在代码执行完之后,生成的文件里面,是这样的
    <?xml version="1.0" encoding="UTF-8"?>
    <urlset
        xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
           http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
    <url>
    <loc>h</loc>
    <priority>h</priority>
    <lastmod>h</lastmod>
    <changefreq>h</changefreq>
    </url>
    <url>
    <loc>1</loc>
    <priority>1</priority>
    <lastmod>1</lastmod>
    <changefreq>1</changefreq>
    </url>
    <url>
    <loc>2</loc>
    <priority>2</priority>
    <lastmod>2</lastmod>
    <changefreq>2</changefreq>
    </url>
    <url>
    <loc>w</loc>
    <priority>w</priority>
    <lastmod>w</lastmod>
    <changefreq>w</changefreq>
    </url>
    </urlset>奇怪吧,就搞不懂这个是怎么回事。
      

  3.   

    你在while结束就把取得的值输出一下,看符合你的期望不
    echo "<pre>";
    print_r($data_array);