2013-05-18 27 views
0

我有一个XML数据库,其中有几个博客文章。一个不同的内容和URL的PHP​​页面

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页面中的博客文章缩略图链接(最后,我想,就像wordpress,但没有使用它),如何加载,更改single.php页面的内容和URL?

如果这是可能的,它是如何工作的搜索引擎优化?

对不起,我是法国人。

回答

2

您可以通过使用GET变量,您将在URL中设置这样做你会

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

有:'$ _GET'变量已经设置的index.php页面上 :在URL链接到该帖子的时候设置$ _GET变量? – Fabio

+0

没有你会通过他们通过URL链接到那个帖子的时候,例如在的index.php Post 121 Ace

+0

我想,这应该是在你的答案 – Fabio

0

首先,您可以为每个帖子添加一个名为“url”的字段,您可以在其中为每个帖子定义自定义网址。 您可以在.htaccess中使用重写url规则。 这里是如何工作的一些相当不错的例子链接: example

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

的single.php中,URL www.example.com.php blog_no = 121

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

您需要:

相关问题