【问题标题】:I can't Master/Detail Page in php我无法在 php 中主页面/详细页面
【发布时间】:2018-03-17 23:55:14
【问题描述】:
<?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 .
.
.
.
问题是当我点击链接时,我被重定向到索引(没有变化),而不是 detail.php。你能解决这个问题吗?谢谢。

【问题讨论】:

  • 这可能太明显了,但你的链接不应该转到detail.php?detail=&lt;?php echo $row["id"]; ?&gt;而不是index.php?details=&lt;?php echo $row["id"]; ?&gt;吗?
  • 在你的地址栏中点击链接后,网址是什么? detail= 之后的任何值?检查页面并查看链接,URL是否正确?
  • "index.php?detail=1"

标签: php mysql database mysqli blogs


【解决方案1】:

您的链接是index.php?detail=,这意味着详细信息将在$_GET 中提供

但是你用$detail_id = $_GET["id"];抓取参数

改成$detail_id = $_GET["detail"];

您也可以通过var_dump($_GET) 尝试一些基本的调试并查看其中的内容。

【讨论】:

    猜你喜欢
    • 2019-08-23
    • 2016-09-22
    • 1970-01-01
    • 2018-09-22
    • 2014-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多