connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT status FROM meme WHERE session='".$q."' ORDER BY id DESC LIMIT 1"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { if($row["status"] == "1"){ echo "Click here"; } else { echo "Processing"; } } } else { echo "0 results"; } $conn->close(); ?>