php 中的动态页面/菜单

Dynamic pages / menu in php

您好,我正在开发某种 CMS 页面,我想在 /index.php 页面上显示所有可用文章的列表,例如 /index.php?p=Art1
而且我不知道该怎么做。
感谢任何帮助。

这是我的 index.php 代码:

<html>
    <head>
        <link rel="stylesheet" href="css/login-layout.css">
    </head>

    <body>
        <div class="dialog-box">
            <h2 style="font-size: 200%;margin-bottom: 0;">Pagini Noi</h2>
            <h3 style="text-align: right; font-size:100%;margin-top: 0;"><a href="login.php">Logheazate</a> pentru a edita paginile</h3>
            <div class="pages">
                <!-- Pagini \/ -->
                <?php
                    include('config.php');

                ?>
            </div>
        </div>
    </body>
</html>

Config.php包含与数据库的连接$db是我使用的变量名。

/index.php?p=Art1 方法实际上是您需要获取的 $_GET。在您当前的示例中,您会这样做:

$p = $_GET['p'];

如果你稍后回显:

echo $p;

你会得到

Art1

但即使在那之前,您也应该向我们提供您希望这样做的一些数据库查询示例,这样我们就可以向您展示如何将变量 $p 传递给一个查询,然后该查询从 table 在你的数据库中。对于简单的 mysql 查询,您可以在此处查看:https://www.w3schools.com/php/func_mysqli_query.asp

警告:请务必使用 mysqli_real_escape_string($p) 以获得对 SQL 注入的最低保护。