一个不同内容和网址的php页面

时间:2013-05-18 11:41:26

标签: php database singlepage

我有一个xml数据库,里面有几篇博文。

xml示例:

<element id="12" size="square" category="portfolio">
    <tag tag="printer printing 3d apple iphone 5 bumper case"></tag>
    <icon class="icon-picture"></icon>
    <urlpage url="/contact/contact.html"></urlpage>
    <urlimage src='./Post thumbnail images/01.png'></urlimage>
    <date date="8 Apr"></date>
    <title>Minimal Bumper for iPhone 5 : Protect your iphone with a lightwheight and protect full case </title>
</element>

我希望我的网站基于两个主要的php页面。 显示博客帖子缩略图和链接的主index.php页面。 还有一个single.php页面,每个博客帖子都可以单独显示。

当我点击index.php页面中的博客帖子缩略图链接时,如何加载,更改single.php页面的内容和网址(最后,我认为,像wordpress但没有使用它)?

如果可行,它对SEO有何用处?

对不起我的英语,我是法国人。

2 个答案:

答案 0 :(得分:2)

您可以使用您将在网址中设置的GET变量来执行此操作:

表示single.php,网址为www.example.com.php?blog_no = 121

if(isset($_GET["blog_no"])) {
     // connect to database and get post
}

链接到该帖子时,您需要在网址中设置$ _GET变量: 在index.php页面上你会

<a href="single.php?blog_no=121">Post 121</a>

答案 1 :(得分:0)

首先,您可以在数据库中为每个帖子添加一个名为“url”的字段,您可以在其中为每个帖子定义自定义网址。 您可以在.htaccess中使用重写网址规则。 这是一个链接,其中包含一些非常好的示例: example

在您的single.php上,您可以从数据库加载动态内容。