Ich habe einen button in php und will das dieser nur angezeigt wird wenn in der Datenbank etwas vorhanden ist. In dem Fall: Antike Münze. Das ist mein Code:
<?php
include ("../html/header.html");
include "connect_database.php";
$sql = "SELECT wert FROM inventar WHERE name='Antike Münze'";
$result = mysqli_query($conn, $sql);
?>
<img src="../img/huette-matrei(3).jpg" width="1500" height="900">
<h1>Was wollen Sie nun sagen?</h1>
<button onclick="window.location.href = 'Schlüssel_nicht_bekommen.php';">Leider habe ich nichts antikes, altes.</button>
<?php
if (mysqli_num_rows($result) > 0) {
?>
<button onclick="window.location.href = 'Kaufen.php';">Ich habe eine antike Münze für dich.</button>
<?php
}
?>
<?php
include "../html/footer.html";
?>
Mein Problem: Der Button wird angezeigt obwohl in der Datenbank nichts drin ist.
Warum funktioniert das so nicht?