0

How to search multiple column, this code search single column , please customise my code

$keywords= "search keywords";
$keywords= htmlspecialchars($keywords);    
$keywords= mysqli_real_escape_string($con, $keywords);
$countSql_s = "SELECT *, MATCH(website) AGAINST ('%".$keywords."%') AS score FROM search WHERE MATCH(website) AGAINST ('%".$keywords."%') ORDER BY score DESC";
Xorifelse
  • 7,878
  • 1
  • 27
  • 38

2 Answers2

0

Just change your "WHERE" to include a check for each column, like this:

... WHERE MATCH(website) AGAINST('%".$keywords."%') > 5
AND MATCH(username) AGAINST('%".$keywords."%') > 5
...
Jeremy Gurr
  • 1,613
  • 8
  • 11
0

You need to alter your table as:

ALTER TABLE --table name-- ADD FULLTEXT fulltext_search (column1,colum2,column3);

Then you can search like this:

MATCH (column1,column2) AGAINST ('%".$keywords."%')
Vikas Umrao
  • 2,800
  • 1
  • 15
  • 23