What is the correct syntax for using the LIKE operator in SQL queries within PHP?

When using the LIKE operator in SQL queries within PHP, you need to properly concatenate the search term with wildcard characters (%) to ensure it functions correctly. This is necessary to perform partial matching in the query.

$searchTerm = "example";
$sql = "SELECT * FROM table_name WHERE column_name LIKE '%" . $searchTerm . "%'";
$result = mysqli_query($connection, $sql);

// Fetch and display results
while($row = mysqli_fetch_assoc($result)) {
    echo $row['column_name'] . "<br>";
}