Php 此处的$get命令有任何错误。。未显示错误,因此未显示结果

Php 此处的$get命令有任何错误。。未显示错误,因此未显示结果,php,mysql,Php,Mysql,Cpanel中没有错误,但浏览器中没有显示任何内容 关于我的代码,我需要直接从浏览器“”中显示$result of status by,以显示所有挂起的表。。但当我在浏览器中执行时,仅显示“” 我对编码一无所知。。这些代码是我从网上和缝纫机上获得的 任何帮助都将不胜感激。。 提前谢谢 <?php require "templates/header.php"; ?> <?php session_start(); if(!$_SESSION['uname']){ header

Cpanel中没有错误,但浏览器中没有显示任何内容

关于我的代码,我需要直接从浏览器“”中显示$result of status by,以显示所有挂起的表。。但当我在浏览器中执行时,仅显示“”

我对编码一无所知。。这些代码是我从网上和缝纫机上获得的

任何帮助都将不胜感激。。 提前谢谢

<?php require "templates/header.php"; ?>

<?php

session_start();
if(!$_SESSION['uname']){
 header('Location: ../index.php');
          }
require "../config.php";
require "../common.php";         

if (isset($_GET['status'])) {
  try {
    $connection = new PDO($dsn, $username, $password, $options);
    $status = $_GET['status'];
    $sql = "SELECT * FROM users WHERE status = :status";
    $statement = $connection->prepare($sql);
    $statement->bindValue(':status', $status);
    $statement->execute();

    $result = $statement->fetch(PDO::FETCH_ASSOC);
  } catch(PDOException $error) {
      echo $sql . "<br>" . $error->getMessage();
  }
} else {
    echo "Something went wrong!";
    exit;
}
?>

<?php  
if (isset($_GET['status'])) {
    if ($result->rowCount() > 0) { ?>
        <h2>Results</h2>

        <table>
            <thead>
                <tr>
                    <th>kode</th>
                    <th>imei</th>
                    <th>nama</th>
                    <th>tipe</th>
                    <th>kerusakan</th>
                    <th>harga</th>
                    <th>status</th>
                    <th>alasan</th>
                    <th>perubahan</th>
                </tr>
            </thead>
            <tbody>
        <?php foreach ($result as $row) { ?>
            <tr>
                <td><?php echo escape($row["kode"]); ?></td>
                <td><?php echo escape($row["imei"]); ?></td>
                <td><?php echo escape($row["nama"]); ?></td>
                <td><?php echo escape($row["tipe"]); ?></td>
                <td><?php echo escape($row["kerusakan"]); ?></td>
                <td><?php echo escape($row["harga"]); ?></td>
                <td><?php echo escape($row["status"]); ?></td>
                <td><?php echo escape($row["alasan"]); ?> </td>
                <td><a href="tutupservis.php?kode=<?php echo escape($row["kode"]); ?>">UPDATE</a></td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
    <?php } else { ?>
        <blockquote>No results found for <?php echo escape($_POST['status']); ?>.</blockquote>
    <?php } 
} ?> 


<a href="index.php">Kembali</a>

<?php require "templates/footer.php"; ?>

结果
科德
伊梅
纳米
酒醉
克鲁萨坎
价格
地位
阿拉桑
佩鲁巴哈
找不到的结果。
仅显示“templates/header.php”
我希望结果显示在挂起状态行中

您的代码似乎没有问题。我不知道,但是

if (isset($_GET["status"]))

为我工作。

首先,确定您的代码中的
$\u GET['status']
确实在按需要获取数据,以便您在处理数据时不必担心这一点

使用以下命令启动php文件:

<?php
$status=$_GET['status'];
echo $status;

我已经通过反复试验解决了这个问题。。
下面是显示我的结果的代码。。
谢谢你的帮助

解决方案正在改变 $result=$statement->fetch(PDO::fetch_ASSOC); 到 $result=$statement->fetchALL(PDO::FETCH_ASSOC)


结果
价格
地位
阿拉桑
佩鲁巴哈
找不到的结果。

我要做的第一件事是
echo$\u GET['status']
并查看它是否包含任何内容。如果从表单
isset()
中设置这些值,则不可靠,因为对于空字符串,此函数将返回true将永远不会在此代码中工作。它需要在代码顶部的第一个字节之前声明。渲染单个字符后,
session\u start()
将不起作用。在加载标题之前开始会话如果你对编码完全陌生,那么在复制/粘贴代码之前,你应该阅读一些手册并理解一些基本逻辑。干杯
<?php require "templates/header.php"; ?>

<?php
session_start();
if(!$_SESSION['uname']){
 header('Location: ../index.php');
          }
require "../config.php";
require "../common.php";         

if (isset($_GET['status'])) {
  try {
    $connection = new PDO($dsn, $username, $password, $options);
    $status = $_GET['status'];
    $sql = "SELECT * FROM users WHERE status = :status";
    $statement = $connection->prepare($sql);
    $statement->bindValue(':status', $status);
    $statement->execute();

    $result = $statement->fetchALL(PDO::FETCH_ASSOC);
  } catch(PDOException $error) {
      echo $sql . "<br>" . $error->getMessage();
  }
} else {
    echo "Something went wrong!";
    exit;
}
?>
<?
if (isset($_GET['status'])) {
    if ($result && $statement->rowCount() > 0) { ?>
        <h2>Results</h2>
        <table>
            <thead>
                <tr>
                    <th>harga</th>
                    <th>status</th>
                    <th>alasan</th>
                    <th>perubahan</th>
                </tr>
            </thead>
            <tbody>
        <?php foreach ($result as $row) { ?>
            <tr>                
                <td><?php echo escape($row["harga"]); ?></td>
                <td><?php echo escape($row["status"]); ?></td>
                <td><?php echo escape($row["alasan"]); ?> </td>
                <td><a href="tutupservis.php?kode=<?php echo escape($row["kode"]); ?>">UPDATE</a></td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
    <?php } else { ?>
        <blockquote>No results found for <?php echo escape($_POST['status']); ?>.</blockquote>
    <?php } 
} ?> 


<a href="index.php">Kembali</a>

<?php require "templates/footer.php"; ?>