I'm using a prepared statement query which is builded with a string concatenation:
$sqlitemsparse
- the "Select" clause$sqlitemsparse .
- the "Where" clause$sqlitemsparse2
- the "Limit" selection
This is working as expected.
Now, additionally, I need the amount of result rows from the $sqlitemsparse
and $sqlitemsparse .
query (without the "LIMIT" selection).
I've tried it with the mysqli_num_rows function in combination with a new mysqli_query but I get the following error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in...
Code:
$conn = new mysqli("localhost", "xxxx", "xxxx", "xxxx");
// Variable to bind
$classid = "4";
$sqlitemsparse = "SELECT * FROM itemSparse INNER JOIN item ON item.id = itemSparse.id";
$sqlitemsparse.= " WHERE item.ClassID = ?";
$sqlitemsparse2 = " LIMIT 0, 10";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sqlitemsparse . $sqlitemsparse2)) {
echo "SQL Failed";
} else {
mysqli_stmt_bind_param($stmt, "s", $classid);
mysqli_stmt_execute($stmt);
$resultitemsparse = mysqli_stmt_get_result($stmt);
while($rowitemsparse = mysqli_fetch_assoc($resultitemsparse)) {
$rowsitemsparse[] = $rowitemsparse;
}
}
$number_filter_row = mysqli_num_rows(mysqli_query($conn, $sqlitemsparse));