In PHP, how can the LIKE operator be utilized to filter data based on the initial letters of words in a database query?

When using the LIKE operator in a SQL query in PHP, you can filter data based on the initial letters of words by using the '%' wildcard character. To filter data based on the initial letters of a word, you can use the query pattern 'word%'. This will match any word that starts with the specified letters.

$search_term = 'A'; // Initial letters to search for
$sql = "SELECT * FROM table_name WHERE column_name LIKE '$search_term%'";
$result = mysqli_query($connection, $sql);

// Loop through the results
while ($row = mysqli_fetch_assoc($result)) {
    // Process each row as needed
}