无法回显执行的查询

时间:2019-06-21 15:25:26

标签: php mysql

无法回显已执行的查询,如下所示:

<?php
$ID=$_GET['id'];
$sql="SELECT * FROM request WHERE repID='$ID' AND status='Stat 
Requested'";
$sqlxc=mysql_query($check);
echo $sqlxc;
?>

我想在请求状态时显示repid的状态。

1 个答案:

答案 0 :(得分:-2)

<?php

$ID=$_GET['id'];

$sql="SELECT * FROM request WHERE repID='$ID' AND status='Stat Requested'";


$result = $conn->query($sql) or die($conn->error);

while($row = $result->fetch_assoc()) {

$Result1= 'Hello '.$row['row1'];
$Result2='Hello '.$row['row2'];

    Echo $Result1;
    Echo $Result2;

 }
?>

//you can also prepare the statement using bind params:

$ID=$_GET['id'];
$stmt =$conn->prepare("SELECT * FROM request WHERE repID=? AND status='Stat Requested'");
$stmt->bind_param("s", $ID);
$stmt->execute();

$result = $stmt->get_result();

if ($result->num_rows > 0) {
while ($row = mysqli_fetch_assoc($result)) {

$Result1= 'Hello '.$row['row1'];
$Result2='Hello '.$row['row2'];

Echo $Result1;
Echo $Result2;
}