How can PHP be used to check if specific words are present in a database table?

To check if specific words are present in a database table using PHP, you can write a SQL query that selects the rows where the column contains the specific words. You can then execute the query using PHP and check if any rows are returned to determine if the words are present in the table.

<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Specific words to check for
$specificWords = array("word1", "word2", "word3");

// Construct SQL query
$sql = "SELECT * FROM table_name WHERE column_name LIKE '%" . implode("%' OR column_name LIKE '%", $specificWords) . "%'";

// Execute query
$result = $conn->query($sql);

// Check if any rows are returned
if ($result->num_rows > 0) {
    echo "Specific words are present in the database table.";
} else {
    echo "Specific words are not present in the database table.";
}

// Close connection
$conn->close();
?>