Something like this should work:
$tagArr = array();
$tagArr = split (", ", $theTags);
$test = mysql_query("SELECT tag_NAME FROM tags");
while ($row = mysql_fetch_array($test)) {
extract($row);
$db_tags[] = $tag_NAME;
}
for ($i = 0; $i < count($tagArr); $i++) {
print ("$tagArr[$i]<br>");
if (in_array($tagArr[$i], $db_tags) {
print ("$tagArr[$i] is in DB<br>");
} else {
print ("$tagArr[$i] is not in DB<br>");
}
}
I'd use a foreach, though:
foreach ($tagArr as $value) {
print ("$value<br>");
if (in_array($value, $db_tags) {
print ("$value is in DB<br>");
} else {
print ("$value is not in DB<br>");
}
}
And you can do without the "extract()":
while ($row = mysql_fetch_array($test)) {
$db_tags[] = $row['tag_NAME'];
}
Edit: You could combine the two loops, too, although the posted tags might show up out of order:
while ($row = mysql_fetch_array($test)) {
extract($row);
if (in_array($tag_NAME, $tagArr)) {
print ("$tag_NAME is in DB<br>");
} else {
print ("$tag_NAME is not in DB<br>");
}
}