PHP,MySQLi – 如何计算查询结果行?

前端之家收集整理的这篇文章主要介绍了PHP,MySQLi – 如何计算查询结果行?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果查询结果为= 1,我应该更换“代码验证?”
我尝试了很多使用num_rows的方法,但它不起作用.
我的 PHP代码
$con=MysqLi_connect("localhost","mbrconsu_un394x","y1cz9,rd+hf6","mbrconsu_mmx");

    if (MysqLi_connect_errno($con))
    {
        echo "Failed to connect to MysqL: " . MysqLi_connect_error();
    }

    $usuario = $con->real_escape_string($_GET['usuario']);
    $senha = $con->real_escape_string($_GET['senha']);

        $query = MysqLi_query($con,"SELECT * FROM 'login' WHERE usuario = '$usuario' AND senha='$senha'");

        if(CODE TO VERIFY IF QUERY RESULT ROW IS = 1){
            while($row = MysqLi_fetch_assoc($query)){
                $db_username = $row['usuario'];
                $db_password = $row['senha'];
            }
            if($usuario == $db_username && $senha == $db_password){
                return true;
            }
            } else {
            return false;
        }

    MysqLi_close($con);
?>
$query->num_rows;

要么

MysqLi_num_rows($query);
原文链接:https://www.f2er.com/php/133436.html

猜你在找的PHP相关文章