【发布时间】:2018-02-09 04:16:16
【问题描述】:
目前我正在开发一个移动图书馆应用程序,该应用程序需要借阅书籍。我希望能够检查与可用总数相比有多少书被签出。我正在努力将mysqli_query 结果转换为一个整数,以便与可用的总书籍数量进行比较。如果这是一个简单的答案(我很新),我深表歉意,因为我做了很多挖掘工作,但找不到适合我的情况的答案。
<?php
require "conn.php";
$userID = "2";
$book_id = "1";
$mysql_qry = "select COUNT(*) from books_checked_out where bookID=$book_id";
$result = mysqli_query($conn, $mysql_qry);
//Somewhere here convert the $result into $quantity, which would be an int
if($quantity >= 2) {
echo "more books checked out than in stock";
}
else if($quantity < 2) {
echo "less books checked out than in stock";
}
?>
感谢您的帮助,谢谢!
【问题讨论】:
-
compared to the total available-> 你将从哪里得到total available?