How can the issue of always displaying a list of all artists instead of search results be addressed in the PHP code?

The issue of always displaying a list of all artists instead of search results can be addressed by implementing a conditional check in the PHP code to determine whether a search query has been submitted. If a search query is present, only display the search results; otherwise, display the full list of artists.

<?php
// Check if a search query has been submitted
if(isset($_GET['search_query'])){
    // Display search results based on the query
    $search_query = $_GET['search_query'];
    // Perform search logic here
    echo "Displaying search results for: " . $search_query;
} else {
    // Display full list of artists
    // Retrieve and display all artists
    $artists = array("Artist 1", "Artist 2", "Artist 3");
    foreach($artists as $artist){
        echo $artist . "<br>";
    }
}
?>