PHP从存储过程获取从DB返回的结果数

时间:2017-12-03 12:31:32

标签: php mysql

我正在尝试使用mysqli_num_rows从数据库中获取结果数,但我不知道使用存储过程传递的参数。我会发布我所做的。在我目前的代码中,Else被执行。我是PHP的新手。

    class CalibresForm(ModelForm):
        class Meta:
            model = models.Calibres
            fields = [
                'calibre',
                'tolerance', ]


    class FichesForm(ModelForm):
        calibres = CalibresForm(ModelForm)

        class Meta:
            model = models.Fiches
            fields = '__all__'

1 个答案:

答案 0 :(得分:1)

$user = mysqli_fetch_assoc($conn);
    if(!empty($user) > 0){

//Store all the users info in session variables
$_SESSION['user_id'] = $user['account_id'];
$_SESSION['user_firstName'] = $user['fname'];
$_SESSION['user_lastName'] = $user['lname'];
$_SESSION['user_password'] = $user['password'];
$_SESSION['user_dob'] = $user['dob'];
$_SESSION['user_joinDate'] = $user['joinDate'];
$_SESSION['user_picture'] = $user['picture'];

//Redirect user to logged in home page
header('Location: home.php');

// If no results are found redirect user to noAccount page
} else {
header('Location: noAccount.php');
}

mysqli_num_rows期待输出结果。

编辑:num_rows期望查询结果不是获取的查询结果。在这种情况下,我建议你使用类似我修改过的代码。