If i’ve database my_table (id,word) as following

and i’ve some posted text called
$name and $comment then i want to know if $name and/or $comment have any words like words i’ve stored in my database my_table (id,word)
$name = "Manal Nor";
$comment = "Hello lovely world";
I can now apply it for only one entry for example $name
$name = "Manal Nor"; // As example no bad words
$sql = "SELECT * FROM my_table";
$result = mysql_query($sql);
$nameArray = explode(" ", $name);
$countname = count($nameArray);
$checkname = 0;
while ($row = mysql_fetch_assoc($result)) {
for ($i=0;$i<$countname;$i++) {
if (strcasecmp($nameArray[$i], $row['word']) == 0) {
$checkname = 1;
}
}
}
if ($checkname == 1) {
echo "banned";
exit;
}
else {
echo "passed";
}
but now the question how to apply it for both $name and/or $comment so that i can give echo "banned"; if either $name and/or $comment have any of the bad words in my_table
The trick here would be to split both variables on word characters with
preg_split()and use the resultant arrays to form anIN()clause to your query.