【发布时间】:2021-09-14 05:53:21
【问题描述】:
我正在尝试学习 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>
我确实搜索过,但所有建议都只是说要使用包含,这当然不是全部需要的。 非常感谢
【问题讨论】:
-
只需使用DIV标签设置布局,然后将include放在DIV内
-
看看模板引擎(我过去使用过 Twig),因为他们倾向于为这类事情构建。他们也可以提供帮助,因为有关于如何使用它们的教程。