我想从返回状态为NULL的表中获取未返回图书的数量......
<?php
require_once("includes/config.php");
if(!empty($_POST["studentid"])) {
$studentid= strtoupper($_POST["studentid"]);
$sth = "SELECT count(*) as total from tblissuedbookdetails where Studentid=:studentid and retrunstatus=NULL";
$query= $dbh -> prepare($sth);
$query-> bindParam(':studentid', $studentid, PDO::PARAM_STR);
$query-> execute();
$results = $query -> fetchAll(PDO::FETCH_OBJ);
echo "<b>Already Issued: </b>".$results->fetch_array;
echo "<script>$('#submit').prop('disabled',false);</script>";
}
?>
最佳答案
基于print_r
,$results
之后$query -> fetchAll(PDO::FETCH_OBJ)
包含数据。
要访问数据,请使用它。
<?php
//...
echo $results[0]->total
//...
?>
看来您的查询结果为total = 0
。如果不是您预期的输出,您可以检查您的数据库。
关于php - NOTICE : Trying to get property of non-object. ..我想从返回状态为NULL的表中获取未返回的图书数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50790895/