“mysqli_num_rows($ query)> 0”未成为现实

时间:2017-10-14 16:30:25

标签: php mysql

我有这个php代码示例,我在数据库表中有几行......但条件(mysqli_num_rows($query) > 0)不满意......

<?php
    include './Dashboard/database_connect.php';

    if (!empty($_POST['firstName']) && !empty($_POST['lastName'])) {
        $fname = $_POST['firstName'];
        $lname = $_POST['lastName'];

        $query = mysqli_query($conn, "SELECT * FROM patient WHERE firstname='$fname' AND lastname='$lname'");
        $row=  mysqli_num_rows($query);

        echo "<script>alert('1')</script>"; 

        if($row>0){ #this if condition is not becoming true, even if I have multiple rows in my database's patient table

            echo "<script>alert('Rows Found')</script>";

        }else{
           echo "<script>alert('No Rows found')</script>"; 
        }
    } else {

        echo "<script>alert('wrong')</script>";
    }
    ?>

任何人都可以帮忙吗???

0 个答案:

没有答案