How can the PHP code be modified to only display records from multiple tables that contain the word "OK" in a specific column?

To only display records from multiple tables that contain the word "OK" in a specific column, you can modify the SQL query in your PHP code to include a WHERE clause that filters for rows where the specific column contains the word "OK". This can be achieved by using the LIKE operator in the WHERE clause along with the % wildcard to match any characters before or after the word "OK".

<?php
// Connect to your 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);
}

// SQL query to select records from multiple tables where a specific column contains the word "OK"
$sql = "SELECT * FROM table1, table2 WHERE table1.column_name LIKE '%OK%' OR table2.column_name LIKE '%OK%'";

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

if ($result->num_rows > 0) {
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo "Column Name: " . $row["column_name"]. "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();
?>