How to render html page base on api response

I’m just trying to display a simple text “No matching lyrics is found” in the UI When ever a user search a song and there is not matching song in the database but not really sure how can I modify it so I would be really appreciated it.

<?php
require_once '../config.php';


if (isset($_POST['submit'])) {
  $title = $_POST['search'];

  $sql = 'SELECT * FROM song WHERE title = :title';
  $stmt = $conn->prepare($sql);
  $stmt->execute(['title' => $title]);
  $row = $stmt->fetch();
} else {
  header('location: .');
  echo 'Not matching found';
  exit();
 
}
?>

<!DOCTYPE html>
<head>Search song</head>
<body>
     <div>
          // Here will be all the content of the song
     </div>
    
     //Show this div if there is no matching song
     <div>
           <p>No matching lyrics is found<p>
     </div>

</body>
</html>

I have tried to do with .show() and hide() but still not working.