Вы можете использовать $mysqli->num_rows
, см. Пример кода ниже.
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$num_references = 0
$res = $mysqli->query("SELECT * FROM references");
$num_references = $res->num_rows;
if ($num_references > 0) {
echo "<h1>Reference</h1>"
}