如何使用PHP和Web创建站点地图的MySQL [英] How to create a sitemap using PHP & MySQL

查看:78
本文介绍了如何使用PHP和Web创建站点地图的MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用PHP& MySQL,您是否知道任何站点地图设计示例?

I was wondering how can I create a sitemap using PHP & MySQL and is there any sitemap design examples you know of?

推荐答案

我在我的网站上使用了它,效果很好,而且您可以将Google的网站站长工具指向"this_file.php",并且效果很好!

I use this on my site, it works well and you can point Google's webmaster tools to "this_file.php" and it works wonders!


<?php
header("Content-type: text/xml");
echo'<?xml version=\'1.0\' encoding=\'UTF-8\'?>';
echo'   <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">';

include '../include.php';
$sql = mysql_query("select blah from bleh");

while ($string = mysql_fetch_array($sql)){?>
            <url>
                <loc>http://www.domain.com/dir/<?echo $string['value'];?>/index.php</loc>
                <changefreq>weekly</changefreq>
            </url>
<?php } ?> 
</urlset>

这篇关于如何使用PHP和Web创建站点地图的MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆