PHP,MySQL,一页网站

at my work we have a system my boss developed where we have one page (index.php), and the different pages are stored within a database instead of different page files.

I was wondering if anyone knew any good tutorials on how to do this? Or if any of you would be able to help me in code it up?

The following tutorial walks you through how to accomplish what you described. However, I would suggest you just skim over it and write something from scratch which uses better coding methods.

http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/content-management-system-cms-using-php-and-mysql.aspx

That's wrong

  • Database is database
  • Business logic is business logic
  • Front end is front end.

That can work for website with less than 15 pages, or static pages, but will be harder to maintain.

You can have what goes inside the body tag in your database in a table with the title and some javascript tags for the header.

Anyhow if what you want is all pages be accessed through the index.php, i will recommend to store the other pages as .php files too, and with some switch/if(whatever) to control the page you will call.

something like:

$pageid = $_GET["pageid"];
switch ($pageid) {
    case 0:
        include('contact.php');
        break;
    case 1:
        include('home.php');
        break;
    case 2:
        include('whoweare.php');
        break;
}

and the url will be something like

http://www.yourwebsite.com/index.php?pageid=1

or

http://www.yourwebsite.com/?pageid=1

References

I will also recommend some links that can help you through this learning season: