一个简单的php/mysql网站的布局 [英] Layout of a simple php/mysql website

查看:43
本文介绍了一个简单的php/mysql网站的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道布置简单网站的最佳方式是什么,我使用了开关,这样我的网站就会包含相同的布局,然后只有一个小的内容区域会随着你去

Id like to know what the best way of laying out a simple website, I used switches so that my website would contain the same layout and then just have a little content area that changes as you go to

myserver/index.php?page=home或者myserver/index.php?page=settings

myserver/index.php?page=home or myserver/index.php?page=settings

这是我的开关的一些代码:index.php:

Here is some code of my switch: index.php:

<?php

session_start();
if (!isset($_SESSION['Username'])) {
    header("Location: login.php");
}
include("config.php");
include("userinfo.php");

if (isset($_GET['page'])) {
    $Page = $_GET['page'];
} else {

} switch ($Page) {

case "logout": {
        require("logout.php");
        include("layout.php");
        break;
    }

case "home": {
        $PageTitle = "Home";
        $PageFileName = "home.php";
        include("layout.php");
        break;
    }

case "music": {
        $PageTitle = "Music";
        $PageFileName = "music.php";
        include("layout.php");
        break;
    }

我基本上想知道,对于具有相同布局但内容部分不同的不同页面,上述系统是否是一个好的系统?

I basicly want to know if the above is a good system for haveing different pages with the same layout but a different content section?

我还可以根据需要使用 php 包含和包含点点滴滴,如标题和侧边栏,但我想知道最好的系统是什么?或者只是任何建议或任何东西.

I could also use php includes and include bits and pieces as I need, like a header and side bar, but Id like to know what the best system is? or just any advice or anything.

谢谢,杰森·拉塞尔

推荐答案

我个人使用如下结构:

  • 主目录:包含所有文件
  • 包含文件夹:有两个文件

然后我创建一个页面,我们称之为 index.php

Then I create a page, let's call it index.php

<?php

include("includes/header.php");

echo "<h1>Page title</h1>";

echo "<p>Page text...</p>";

include("footer.php");

?>

然后我为每个页面编写一个脚本并将它们全部分开.你上面的方法看起来非常复杂,用不了多久你就会很迷茫!

I then write a script for each page and keep it all separate. Your method above seems extremely complicated and you will get very very confused after not very long!

此外,拆分页眉/页脚的最佳方法是在一个文件中按照您的需要进行布局.然后找到主DIV的开头和主DIV的结尾,将顶部放在页眉中,底部放在页脚中.

Also, the best way to split the header/footer is to make the layout as you want it in one file. Then locate the beginning of the main DIV and the end of the main DIV and put the top part in the header, bottom part in the footer.

我尽量保持简单.我希望有帮助:)

I tried to keep that as simple as possible. I hope that helps :)

这篇关于一个简单的php/mysql网站的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆