开发者

PHP, MySQL, One page Website

开发者 https://www.devze.com 2023-01-14 17:54 出处:网络
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.

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 wa开发者_JAVA百科s 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?


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:

  • PHP Manual
  • Building Dynamic Web Pages with PHP
  • First Web Page


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

0

精彩评论

暂无评论...
验证码 换一张
取 消