I have a Array with data, and I am looping through the data.
For each string, I want to check if it is present in the database (whole table). It might be there inside another string (so if the table contains heyredcat, and you check for red, it also returns true).
I've came up with this sample script, but I can't come up with a MySQL query, Googling resulted in many great suggestions for "if column equals string" but not for a string in the whole table.
<?php
$colors = array("red","green","blue","yellow");
foreach ($colors as $value)
{
$result = mysql_query("SELECT * FROM products where $value ...... ") or die(mysql_error());
if($result){
echo "Color" .$value. "is present";
else {
echo "Color" .$value. "is not present";
}
}
?>
What MySQL query should I use? Also, I'm wonding, is this an efficient way to do this? (time consuming)