How to insert comma separated values of textarea in mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phphunger
Forum Commoner
Posts: 45
Joined: Tue Aug 11, 2009 11:56 pm

How to insert comma separated values of textarea in mysql

Post 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.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post by jackpf »

Look into explode() and foreach().
uyewq
Forum Newbie
Posts: 22
Joined: Thu Sep 17, 2009 6:21 am

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

Post 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
phphunger
Forum Commoner
Posts: 45
Joined: Tue Aug 11, 2009 11:56 pm

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

Post by phphunger »

Thanks mates...Thank you for your solution...

Cheers...
Post Reply