Sure. First you need to understand what the goal is. We have a string of keywords, separated by spaces, and we want to find all of the (e-mails, in your case) which contain any of those words.
So, the first thing we need to do is separate our long string of keywords into a more manageable array:
$parts = explode(" ",$keyword);
Now, we need to begin the query. One of two problems with your own code is that it assumes there is at least one search term. Instead of your line 2 I would write:
$sql = "SELECT DISTINCT(e_mail) FROM test WHERE (";
Now we need to add each keyword to the query as a search parameter. so we construct a for() loop that will iterate across the keyword array:
for($i = 0; $i < sizeof($keyword); $i++) {
Now, if this is not the first element, we need the word "OR" to separate the elements:
if($i > 0) {
$sql .= " OR ";
}
The other mistake you made in your code was leaving out the wildcard characters (%) in the second part of your query. We need to add each parameter in a LIKE clause so that we can use those characters and search for the keyword WITHIN the body of the e-mail:
$sql .= "(section LIKE '%$keyword[$i]%')";
}
Now all that's left is closing the query string. Semicolons at the end of queries are only required when you are actually running SQL from the command-line.
$sql .= ")";
Hope that helps!