thientanchuong
20-06-2012, 05:43
Mình tạo ra 4 file khác nhau:
index.php = > chứa đường dẫn include với body.php và menu.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="CSS/myform.css" />
<title>Ebay Management System</title>
</head>
<body background="image/VietMartBackground.jpg">
<table width="100%" border="1">
<tr>
<td>
<form name="FormSearch" action="../function/searchProcess.php" method="post" />
<input name="searchText" title="searchText" type="text" width="400"/>
<input name="SearchButton" title="SearchButton" Type="Submit" value="Search"/>
</form>
</td>
</tr>
<tr>
<td>
<?php
include 'template/menu.php';
?>
</td>
</tr>
<tr>
<td>
<?php
include 'template/body.php';
?>
</td>
</tr>
</table>
</body>
</html>
menu.php => nằm trong folder template
<link rel="stylesheet" type="text/css" href="../CSS/menu.css" />
<ul id="nav">
<li>
<a href="index.php?page=body">Home</a>
</li>
<li>
<a href="#">Supplier</a>
<ul>
<li><a href="index.php?page=supplierAdd" name="supplierAdd">Add New Suppliers</a></li>
<li><a href="index.php?page=supplierList" name="supplierList">List All Suppliers</a></li>
</ul>
</li>
<li>
<a href="#">Items</a>
<ul>
<li><a href="index.php?page=itemAdd" name="itemAdd">Add New Items</a></li>
<li><a href="index.php?page=itemList" name="itemList">List All Items</a></li>
</ul>
</li>
<li>
<a href="#">Catalogue</a>
<ul>
<li><a href="index.php?page=catalogueAdd" name="catalogueAdd">Add New Catalogue</a></li>
<li><a href="index.php?page=catalogueList" name="catalogueList">List All Catalogues</a></li>
</ul>
</li>
<li>
<a href="#">Ebay Sale</a>
<ul>
<li><a href="index.php?page=dailySaleRecords" name="dailySaleRecords">Daily Sale Records</a></li>
<li><a href="index.php?page=totalProfitChecking" name="totalProfitChecking">Total Profit Checking</a></li>
</ul>
</li>
<li>
<a href="#">Ebay Problem Collection</a>
<ul>
<li><a href="index.php?page=problemAdd" name="problemAdd">Add New Problems</a></li>
<li><a href="index.php?page=problemList" name="problemList">List All Problems</a></li>
</ul>
</li>
</ul>
menu.css => nằm trong folder CSS
/*------------------------------------*\
NAV
\*------------------------------------*/
#nav{
list-style:none;
font-weight:bold;
margin-bottom:10px;
/* Clear floats */
float:left;
width:100%;
/* Bring the nav above everything else--uncomment if needed.
position:relative;
z-index:5;
*/
}
#nav li{
float:left;
margin-right:10px;
position:relative;
}
#nav a{
display:block;
padding:5px;
color:#fff;
background:#333;
text-decoration:none;
}
#nav a:hover{
color:#fff;
background:#6b0c36;
text-decoration:underline;
}
/*--- DROPDOWN ---*/
#nav ul{
background:#fff; /* Adding a background makes the dropdown work properly in IE7+.
Make this as close to your page's background as possible (i.e. white page == white background). */
background:rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */
list-style:none;
position:absolute;
left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */
}
#nav ul li{
padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */
float:none;
}
#nav ul a{
white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
#nav li:hover ul{ /* Display the dropdown on hover */
left:-40px; /* Bring back on-screen when needed */
}
#nav li:hover a{ /* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
background:#6b0c36;
text-decoration:underline;
}
#nav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration:none;
}
#nav li:hover ul li a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
background:#333;
}
body.php => chứa SWITCH CASE code.
<?php
$page = isset($_GET['page']) ?$_GET['page'] : 1;
switch ($page){
case "supplierAdd":
include("supplierAdd.php");
break;
case "supplierList":
include("supplierList.php");
break;
case "itemAdd":
include("itemAdd.php");
break;
case "itemList":
include("itemList.php");
break;
case "catalogueAdd":
include("catalogueAdd.php");
break;
case "catalogueList":
include("catalogueList.php");
break;
case "dailySaleRecords":
include("dailySaleRecords.php");
break;
case "totalProfitChecking":
include("totalProfitChecking.php");
break;
case "problemAdd":
include("problemAdd.php");
break;
case "problemList":
include("problemList.php");
break;
default:
include ("body.php");
}
?>
ở đây, mình có tới 2 trường hợp xảy ra lỗi
1/ Trường hợp 1 có 2 lỗi
Lỗi ko hiển thị kiểu dáng menu
http://img713.imageshack.us/img713/2040/menuerror.jpg
nhưng các đường truyền đều ok hết ko bị lỗi
lỗi báo ở index.php
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6144 bytes) in D:\xampp\htdocs\EBAY\template\body.php on line 40
=> cái này làm sao sửa lỗi đây bạn.
2/ Lỗi báo ở đường truyền
Nếu mình ko thông qua index.php mà bật ngay menu.php thì có giao diện đúng như mình muốn
http://img12.imageshack.us/img12/7608/menudq.jpg
nhưng sau đó bấm vào bất kì trên menu thì nó báo OBJECT NOT FOUND
http://img535.imageshack.us/img535/7936/duongtruyenerror.jpg
Làm sao sửa các lỗi trên vậy các bạn
index.php = > chứa đường dẫn include với body.php và menu.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="CSS/myform.css" />
<title>Ebay Management System</title>
</head>
<body background="image/VietMartBackground.jpg">
<table width="100%" border="1">
<tr>
<td>
<form name="FormSearch" action="../function/searchProcess.php" method="post" />
<input name="searchText" title="searchText" type="text" width="400"/>
<input name="SearchButton" title="SearchButton" Type="Submit" value="Search"/>
</form>
</td>
</tr>
<tr>
<td>
<?php
include 'template/menu.php';
?>
</td>
</tr>
<tr>
<td>
<?php
include 'template/body.php';
?>
</td>
</tr>
</table>
</body>
</html>
menu.php => nằm trong folder template
<link rel="stylesheet" type="text/css" href="../CSS/menu.css" />
<ul id="nav">
<li>
<a href="index.php?page=body">Home</a>
</li>
<li>
<a href="#">Supplier</a>
<ul>
<li><a href="index.php?page=supplierAdd" name="supplierAdd">Add New Suppliers</a></li>
<li><a href="index.php?page=supplierList" name="supplierList">List All Suppliers</a></li>
</ul>
</li>
<li>
<a href="#">Items</a>
<ul>
<li><a href="index.php?page=itemAdd" name="itemAdd">Add New Items</a></li>
<li><a href="index.php?page=itemList" name="itemList">List All Items</a></li>
</ul>
</li>
<li>
<a href="#">Catalogue</a>
<ul>
<li><a href="index.php?page=catalogueAdd" name="catalogueAdd">Add New Catalogue</a></li>
<li><a href="index.php?page=catalogueList" name="catalogueList">List All Catalogues</a></li>
</ul>
</li>
<li>
<a href="#">Ebay Sale</a>
<ul>
<li><a href="index.php?page=dailySaleRecords" name="dailySaleRecords">Daily Sale Records</a></li>
<li><a href="index.php?page=totalProfitChecking" name="totalProfitChecking">Total Profit Checking</a></li>
</ul>
</li>
<li>
<a href="#">Ebay Problem Collection</a>
<ul>
<li><a href="index.php?page=problemAdd" name="problemAdd">Add New Problems</a></li>
<li><a href="index.php?page=problemList" name="problemList">List All Problems</a></li>
</ul>
</li>
</ul>
menu.css => nằm trong folder CSS
/*------------------------------------*\
NAV
\*------------------------------------*/
#nav{
list-style:none;
font-weight:bold;
margin-bottom:10px;
/* Clear floats */
float:left;
width:100%;
/* Bring the nav above everything else--uncomment if needed.
position:relative;
z-index:5;
*/
}
#nav li{
float:left;
margin-right:10px;
position:relative;
}
#nav a{
display:block;
padding:5px;
color:#fff;
background:#333;
text-decoration:none;
}
#nav a:hover{
color:#fff;
background:#6b0c36;
text-decoration:underline;
}
/*--- DROPDOWN ---*/
#nav ul{
background:#fff; /* Adding a background makes the dropdown work properly in IE7+.
Make this as close to your page's background as possible (i.e. white page == white background). */
background:rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */
list-style:none;
position:absolute;
left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */
}
#nav ul li{
padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */
float:none;
}
#nav ul a{
white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
#nav li:hover ul{ /* Display the dropdown on hover */
left:-40px; /* Bring back on-screen when needed */
}
#nav li:hover a{ /* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
background:#6b0c36;
text-decoration:underline;
}
#nav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration:none;
}
#nav li:hover ul li a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
background:#333;
}
body.php => chứa SWITCH CASE code.
<?php
$page = isset($_GET['page']) ?$_GET['page'] : 1;
switch ($page){
case "supplierAdd":
include("supplierAdd.php");
break;
case "supplierList":
include("supplierList.php");
break;
case "itemAdd":
include("itemAdd.php");
break;
case "itemList":
include("itemList.php");
break;
case "catalogueAdd":
include("catalogueAdd.php");
break;
case "catalogueList":
include("catalogueList.php");
break;
case "dailySaleRecords":
include("dailySaleRecords.php");
break;
case "totalProfitChecking":
include("totalProfitChecking.php");
break;
case "problemAdd":
include("problemAdd.php");
break;
case "problemList":
include("problemList.php");
break;
default:
include ("body.php");
}
?>
ở đây, mình có tới 2 trường hợp xảy ra lỗi
1/ Trường hợp 1 có 2 lỗi
Lỗi ko hiển thị kiểu dáng menu
http://img713.imageshack.us/img713/2040/menuerror.jpg
nhưng các đường truyền đều ok hết ko bị lỗi
lỗi báo ở index.php
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6144 bytes) in D:\xampp\htdocs\EBAY\template\body.php on line 40
=> cái này làm sao sửa lỗi đây bạn.
2/ Lỗi báo ở đường truyền
Nếu mình ko thông qua index.php mà bật ngay menu.php thì có giao diện đúng như mình muốn
http://img12.imageshack.us/img12/7608/menudq.jpg
nhưng sau đó bấm vào bất kì trên menu thì nó báo OBJECT NOT FOUND
http://img535.imageshack.us/img535/7936/duongtruyenerror.jpg
Làm sao sửa các lỗi trên vậy các bạn