Hey people,
Wondered if you might be able to give me a quick hand with something.
I have a form that allows a user to enter a number of keywords, seperated by commas, into a text box. So the user might type "penguin, sausage, spider, table".
What I want to do is then explode this string into an array and store each element in the array as a separate record in my keywords table.
The code I currently have is
$keywords = $_POST['keywords'];
$keywords = preg_replace("/[^a-z0-9,. ]/i", "", $keywords);
$keywords = explode(",",$keywords);
foreach($keywords as $keywords => $VALUE) {
mysql_query("INSERT INTO keywords (keyword) VALUES ($VALUE)");}
Now I am probably making a very fundamental error with this code and I wondered if someone might be able to point it out for me?
As always, thanks for all your help 🙂