I am trying to create a javascript that split the tags (that the user gives, separated them with comma (,)) and pass them in my database in different rows but with the same id.
i have this code:
<form name="formatform" method="post" onsubmit="return validate_format_form()" action="formatsubmit.php">
<p>
Συντομος Τιτλος:<input type="text" name="titlos" value="">
Συντομη περιγραφη:<input type="text" name="perigrafi" value="">
</p>
<p>
Τοποθεσια:<input type="text" id="loc" name="topothesia" value="">
Tags:<input type="text" name="tags" value="">
**Οι ετικέτες πρέπει να χωρίζονται με κόμμα
</p>
.
.
.
</form>
and in formatsubmit.php which is the one who pass them into database these code:
$query= " INSERT into photos(`title`,`description`,`location`,`privilages`,`ph_tags`) VALUES ('".$_POST['titlos']."','".$_POST['perigrafi']."','".$_POST['topothesia']."','".$_POST['radio_check']."','".$_POST['tags']."') ";
$result= mysql_query($query,$con);
If the user gives 3 tags(separated with comma) i want to split them and pass them to database in different rows.
How can i do that?
How about splitting the tag input into an array using comma as the delimiter and then iterating over the tags and creating one insert statement per tag? E.g.