0

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.

4
Contributors
5
Replies
9
Views
7 Years
Discussion Span
Last Post by metalix
0

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;
?>

Edited by muralikalpana: n/a

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.