php生成sitemap的案例 本帖最后由 sslook 于 2012-08-10 17:37:17 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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; } 现在代码执行完之后,生成的文件里面,是这样的<?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>奇怪吧,就搞不懂这个是怎么回事。 你在while结束就把取得的值输出一下,看符合你的期望不echo "<pre>";print_r($data_array); PHP 完成.NET ___STATESVIEW查看功能 关于是时间戳对比的问题 新手遇到setcookie的问题??? 求教一个简单的问题 这样的文本值怎么取 php求救,做不出来就没工作了! php 收录批量查询 只能查一条 PHP的树型菜单 请教各位高手,在嵌套查询中如何实现分页显示,急,在线等待。。。。 推荐适合初学者看的php入门书籍 dreamweaver連接mysql數據庫連接不上 关于PHP正则表达式提取远程页面中的Table内容
{ $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;
}
<?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>奇怪吧,就搞不懂这个是怎么回事。
echo "<pre>";
print_r($data_array);