Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP页面上获取SQL ID并将其传递到另一个PHP页面_Php_Mysql - Fatal编程技术网

在PHP页面上获取SQL ID并将其传递到另一个PHP页面

在PHP页面上获取SQL ID并将其传递到另一个PHP页面,php,mysql,Php,Mysql,有人能帮我从SQL中获取ID变量并将其发送到另一个PHP页面吗? index.php输出:(Image1) checks.php输出:(Image2) 我需要完成以下几点: 每当我在index.php页面的状态字段下单击“OK”或“NOK”时,我需要它将我带到另一个名为checks.php的php页面,并显示我单击的行的ID 例如,在Image1(这是index.php页面)上,如果我在ID=2的状态列下单击OK,我想将这个ID转换为变量,并将其传递到下一页checks.php以仅显示ID=

有人能帮我从SQL中获取
ID
变量并将其发送到另一个PHP页面吗?
index.php
输出:(Image1)

checks.php
输出:(Image2)

我需要完成以下几点: 每当我在
index.php
页面的状态字段下单击“OK”或“NOK”时,我需要它将我带到另一个名为
checks.php
的php页面,并显示我单击的行的
ID

例如,在Image1(这是
index.php
页面)上,如果我在ID=2的状态列下单击OK,我想将这个
ID
转换为变量,并将其传递到下一页
checks.php
以仅显示ID=2的行,而不是表中的所有
ID

这是我的
index.php
code

<?php
    require_once('connection.php');
    $result = $conn->prepare("SELECT * FROM report");
    $result->execute();
    for($i=0; $row = $result->fetch(); $i++){
?>
    <tr>
        <td><label><?php echo $row['ID']; ?></label></td>
        <td><label><?php echo $row['ElapsedTime']; ?></label></td>
        <td><label><?php echo $row['Computer']; ?></label></td>
        <td><label><?php echo $row['Manufacturer']; ?></label></td>
        <td><label><?php echo $row['ModelName']; ?></label></td>
        <td><label><?php echo $row['UserType']; ?></label></td>
        <td><label><?php echo $row['UserName']; ?></label></td>
        <td><label><a href='checks.php?id=". urlencode($row['ID']) ."'><?php echo $row['Status']; ?></a></label></td>
    </tr>
    <?php } ?>
<?php
    require_once('connection.php');
    $id = $_GET['id'];
    $result = $conn->prepare("SELECT * FROM checks,report where checks.ID = report.ID and checks.ID = $id");
    $result->execute();
    for($i=0; $row = $result->fetch(); $i++){
?>
    <tr>
        <td><label><?php echo $row['ID']; ?></label></td>
        <td><label><?php echo $row['WiFi']; ?></label></td>
        <td><label><?php echo $row['Printers']; ?></label></td>
        <td><label><?php echo $row['Notepad']; ?></label></td>
    </tr>
    <?php } ?>

如果我手动设置
ID
,例如,它工作正常

您的问题在于HTML代码的最后一行
td

<td><label><a href='checks.php?id=". urlencode($row['ID']) ."'><?php echo $row['Status']; ?></a></label></td>
我还使用了短标记
,而不是

<td><label><a href='checks.php?id=<?= $row['ID'] ?>'><?= $row['Status'] ?></a></label></td>