Question

I have an xml database where are stocked several blog posts.

xml example:

<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>

I want to have my website based on two main php pages. The main index.php page where blog post thumbnails and links are displayed. And a single.php page where each blog posts can be displayed individually.

How can I load, change the content and url of the single.php page when I click on a blog post thumbnail link in the index.php page (finally, I think, like wordpress but without use it)?

If this is possible, how it works for SEO?

Sorry for my english, I'm french.

Était-ce utile?

La solution

You can do this by using GET variables which you will set in the url:

for single.php, url www.example.com.php?blog_no=121

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

You need to set $_GET variable in the url when linking to that post: on the index.php page you would

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

Autres conseils

First of all, you can add in your database for each post, a field named "url", where you can define a custom url for every post. You can use the rewrite url rule in .htaccess. Here is a link with some pretty nice examples of how this works: example

On your single.php you can load your content dynamical from your database.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top