I have an HTML search box which have an SQL query which should display data if the word matches any of 4 columns in table.
<?php
$link = mysqli_connect("localhost", "root", "", "sample");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
if(isset($_REQUEST["search"])){
$sql = "SELECT * FROM image_gallery WHERE key1 OR key2 OR key3 OR key4 LIKE ?";
if($stmt = mysqli_prepare($link, $sql)){
mysqli_stmt_bind_param($stmt, "s", $param_term);
$param_term = $_REQUEST["search"] . '%';
if(mysqli_stmt_execute($stmt)){
$result = mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){?>
SQL column
This is the complete SQL code, its displaying data sometimes only when word matches last column, doesn't display for first 3 columns when I type corresponding word.