<?php
require "includes/config.php";
require "includes/header.php";
$query = mysqli_query($conn, "SELECT * FROM post ORDER BY id DESC");
?>
这是index.php的顶部
.
.
.
.
include "includes/header.php";
include "includes/config.php";
$detail_id = $_GET["id"];
$query = mysqli_query($conn, "SELECT * FROM post WHERE post.id = '$detail_id'");
$row_detail = mysqli_fetch_array($query)
?>
这是detail.php的顶部
.
.
.
.
<a href="index.php?detail=<?php echo $row["id"]; ?>">
链接到detail.php
.
.
.
.
问题是当我点击链接时,我被重定向到index(没有变化),而不是detail.php。你能解决这个问题吗?谢谢。
最佳答案
您的链接是index.php?detail=
,这意味着详细信息将在$_GET
中提供
但是您正在使用 $detail_id = $_GET["id"]; 获取参数
将其更改为$detail_id = $_GET["detail"];
您还可以尝试一些基本的调试,通过 var_dump($_GET)
并查看其中的内容。
关于php - 我无法在 php 中设置主页面/详细信息页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49343141/