I'm coding my own blog which is almost completing. I'm facing a problem on one thing. How can I insert comma separated tags in mysql table? I want to insert every comma separated tag as the new entry in the table.

I would be thankful if anyone will help me out with it.

use explode() for it. count the size of that array . then looping for insert each tag separate

<?php
// Example 1
$pizza  = "piece1,piece2,piece3,piece4,piece5,piece6";
$pieces = explode(",",$pizza);
$count=count($pieces);
for($i=0;$i<$count;$i++)
{
echo $pieces[$i]; // piece1

//write insert query here.
}
exit;
?>

yes explode is the only way for this.
but as a note for your blog make sure you prevent all hacking attempts.
My bloggs get several failed hacking attempts daily.
convert "&" to "&am p;" "<" to "&l t;" and ">" to "&gt ;" in that order to start with. because you don't want people entering bad iframes or images ect. theres a read-me here on some basic stuff for this

use implode(); function to insert comma separated tags in mysql table. do you want display tags without comma use explode() function.

Thanks for all the replies.. The explode has solved my problem.
Thanks once again

No worries.
remember to mark thread as solved when solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.