0

我有一个 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 页面的内容和 url(最后,我认为,就像 wordpress 但没有使用它)?

如果这是可能的,它是如何为 SEO 工作的?

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

4

2 回答 2

2

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

对于 single.php,网址为 www.example.com.php?blog_no=121

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

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

<a href="single.php?blog_no=121">Post 121</a>
于 2013-05-18T11:52:11.690 回答
0

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

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

于 2013-05-18T11:51:48.943 回答