PHP, MySQL, One page Website
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 databaseBusiness logic
is business logicFront 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
精彩评论