What is the limitation of using PHP alone to change a SQL query without reloading the page?

The limitation of using PHP alone to change a SQL query without reloading the page is that PHP is a server-side language, meaning it executes on the server before the page is rendered on the client-side. To dynamically change a SQL query without reloading the page, you would need to use JavaScript to make an asynchronous request to the server, where PHP processes the new query and returns the updated data to the client.

// PHP code to handle AJAX request and dynamically change SQL query

if(isset($_POST['newQuery'])) {
    // Sanitize and validate input
    $newQuery = $_POST['newQuery'];

    // Execute the new SQL query
    // $result = mysqli_query($connection, $newQuery);

    // Process the result and return data to client
    // echo json_encode($result);
}