<form name="attdate" action="keyword.php" method="post">
Enter Keyword :<input name = "key">
<button class='btn btn-lg btn-danger' type ="submit"> Search Records</button>
What I am trying to do is query my varchar fields with a keyword (wildcard) search:
The fields in the rows that I want to query are 'hs' 'nv' 'vsa' .
My PHP looks like this :
<?php
include 'config.php';
$key = ($_POST['key']);
$key = mysqli_real_escape_string($con,$key);
$sql = "SELECT * FROM handover WHERE hs LIKE "%'.$key.'%"
OR WHERE nv LIKE "%'.$key.'%"
OR WHERE vsa LIKE "%'.$key.'%"";
$result = mysqli_query($con,$sql);
$count=mysqli_num_rows($result);
if($count==0 ){
echo "</br></br></br></br></br></br></br><h2>Handover Details</h2><p> No Matching
results found</p>";
}
else{
while($row = mysqli_fetch_array($result)) {
echo '</br></br></br></br></br>';
I think it might be where I am putting the %. The column is not part of the index is this a problem?
thanks in advance