I'm Trying to get a php string to break down into individual words, search for them in a database and then add the results into another database..
I currently have the string like this
"SDGCC, ARISE, SDGFS"
I want to search in the login tags table for tags LIKE these words i'm using this
SELECT * FROM
logintags
WHEREtag
LIKE '%string%'
so that each tag is taken from the string i've tried using explode and foreach but it doesn't seem to be getting the desired effect.
$string = $_POST['tags'];
$tags = explode(',' $string);
foreach($tags as $key) {
$query = mysql_query("SELECT * FROM
dept_logintags
WHEREtag
LIKE '%".$key."%'"); $r = mysql _fetch _object($query);$insert = mysql_query("INSERT INTO
briefings_logintags
(id
,briefing_id
,logintag_id
) VALUES (NULL, '$id', '".$r->id."')");}
the effect i'm trying to create is for each tag create a reference between the tag id and the briefing id...
However it seems only to be putting one correct entry in the database.