MySQL获取查询PHP

时间:2018-12-09 12:02:56

标签: php mysql mysqli

表中只有30个值,但mysqli_num_rows($result) return 60 同一查询执行两次,代码如下:

<?php 

error_reporting(E_ALL);
$con=mysqli_connect('127.0.0.1','***','***','***');
if (mysqli_connect_errno()) {
    # code...
    echo "Could not connect to MYSQL database".mysqli_connect_error();
}

$sql = "select * from ticket_staff";
$result = mysqli_query($con, $sql);
echo mysqli_num_rows($result);
if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        echo   $row["t_ID"]."<br>";
    }
} else {
    echo "0 results";
}


?>

here is the screenshot of output

0 个答案:

没有答案