>Can somebody help me with this or point me in the right direction. >an example of what i need >I have a string that has 4 items in it separated by a space >$string="item1 item2 item3 item4"; >I also have a database with a lot of other items in it. > >I what to compare the items in the string with the items in the >database and if any of them match to branch of and do something >different with the data. if they don't match do something else with the >data. I hope this makes sense
You haven't described the database in enough detail to be sure, but assuming you have one row for every item, you could do this: <?php $string = "item1 item2 item3 item4"; $items = explode("', '", $string); $query = "select count(*) from whatever where item in ('$items')"; $itemcount = @mysql_query($query, $connection) or error_log(mysql_error()); $itemcount = @mysql_result($itemcount, 0, 0); if ($itemcount){ } ?> -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php