我正在尝试学习 PHP(作为一名 C# 程序员),到目前为止它并不困难(获取数据库记录,登录...),但我认为很容易的事情实际上并不是,对我来说 -我学会了使用“include”关键字来注入其他文件的内容。但是,我无法弄清楚如何影响设计,我想在左侧边栏中获取数据库记录(为此我编写了用于查询的 sidebar.php 和用于显示详细信息的 page.php,所以这是主要的内容元素):
<?php
include('session.php');
?>
<html">
<head>
<title>My catalogue</title>
</head>
<body>
<h2><a href = "logout.php">Sign Out</a></h2>
</body>
//I would need this to be always on the left
<?php include("sidelist.php"); ?>
//This should be the main content of the page
<?php include("page.php"); ?>
</html>
我确实进行了搜索,但所有建议都只说明使用包含,这当然不是所有需要的。 非常感谢
答案 0 :(得分:2)
每当您谈论布局时,您都会处理 HTML 和 CSS。
将你的两个包含在 div 中,然后创建一些 css 类来根据需要格式化布局,例如
<?php
include('session.php');
?>
<html">
<head>
<title>My catalogue</title>
</head>
<body>
<h2><a href = "logout.php">Sign Out</a></h2>
</body>
//I would need this to be always on the left
<div id="sidelist">
<?php include("sidelist.php"); ?>
</div>
//This should be the main content of the page
<div id="main">
<?php include("page.php"); ?>
</div>
</html>
然后 CSS 可能看起来像
#sidelist{
float:left;
width:75%;
overflow:hidden;
}
#main{
float:left;
width:25%;
overflow:hidden;
}