I have a string with tag names separated by comas ready for insertion into a MySQL table, for example:
$tags = " 'pigs','dogs','cats' "
I have a mySQL table called tags containing a tag_id and tag_name.
I want to insert each tag into the table. Is this possible in one INSERT query using the string I have, or will I have to run a loop with an array of the tag names?
You could do:
And if you were to echo out
$sqlyou should get: