To search through an entire database in mysqli, you can use a SELECT statement with the LIKE operator . Here's an example:
<?php
$conn = mysqli_connect("localhost", "username", "password", "database_name");
$search_term = "apple";
$query = "SELECT * FROM `table_name` WHERE CONCAT_WS(' ', `column1`, `column2`, `column3`) LIKE '%$search_term%'";
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo $row['column1'] . " " . $row['column2'] . " " . $row['column3'] . "<br>";
}
} else {
echo "No results found.";
}
mysqli_close($conn);
?>
In this example, we first connect to the database using mysqli_connect(). We then define the search term and construct the query using the CONCAT_WS function to combine multiple columns into one string to search. We use the LIKE operator with wildcard characters (%) to search for the search term in any part of the concatenated string . We then execute the query using mysqli_query() and loop through the results using mysqli_fetch_assoc(). Finally, we close the connection using mysqli_close().