I want to verify if it's more than one result.
Code:
<?php
if (!isset($_GET["q"])) {
echo "";
} else {
$res = "%{$_GET["q"]}%";
$sql = "SELECT * FROM announce WHERE title LIKE ? ";
$stmt = mysqli_stmt_init($conn);
mysqli_stmt_prepare($stmt, $sql);
mysqli_stmt_bind_param($stmt, "s", $res);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($result > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo '<a href="./invideo.php?movieID=' . $row["idAnn"] . '">' . $row["title"] . '</a>';
}
} else {
echo "0 results";
}
}
?>
But get this error:
Notice: Object of class mysqli_result could not be converted to int in C:\xampp\htdocs\site\search_page.php on line 110
Problem:
$result = mysqli_stmt_get_result($stmt);
if ($result > 0)