Page 1 of 1

How to insert comma separated values of textarea in mysql

Posted: Tue Sep 29, 2009 12:07 am
by phphunger
Hi,

Can anyone tell me that how to insert the multiple comma separated values of Text Area field in MySQL database using php. As i want to take each value from the Text Area and then insert into the MySQL one after one. Can anyone provide small code for this. Thanks in advance.

Re: How to insert comma separated values of textarea in mysql

Posted: Tue Sep 29, 2009 5:51 am
by jackpf
Look into explode() and foreach().

Re: How to insert comma separated values of textarea in mysql

Posted: Tue Sep 29, 2009 6:15 am
by uyewq
Hi phphunger,

Code: Select all

<?php
$textarea ="this script explodes words one by one and print each in comma seperated form.";
$textarea_array= explode(" ",$textarea);
 
for($i=0;$i<count($textarea_array);$i++) {
echo $textarea_array[$i].', ';
}
?>
Output of the php code above:
this, script, explodes, words, one, by, one, and, print, each, in, comma, seperated, form.,

Bye

Re: How to insert comma separated values of textarea in mysql

Posted: Tue Sep 29, 2009 11:38 pm
by phphunger
Thanks mates...Thank you for your solution...

Cheers...