lynxus Posted October 25, 2010 Share Posted October 25, 2010 Hi Guys, I have a textarea on a html page with XXX amount of lines. How can I in php insert a separate mysqlrow for EACH line on the html textarea? Thanks G Link to comment https://forums.phpfreaks.com/topic/216763-insert-a-new-row-in-mysql-for-each-line-in-a-html-textarea/ Share on other sites More sharing options...
vichu.1985 Posted October 25, 2010 Share Posted October 25, 2010 Dude, I assume that every line is separated by "Enter key"(At the end of line you have pressed enter key) in the Textarea. In this case you can use the following code and get the textarea value in array format and write insert query to it...... $values = $_POST['textarea_name']; $array = split("\r\n", $values); foreach($array as $line){ mysql_query("insert into table(field) values($line)"); } Link to comment https://forums.phpfreaks.com/topic/216763-insert-a-new-row-in-mysql-for-each-line-in-a-html-textarea/#findComment-1126124 Share on other sites More sharing options...
lynxus Posted October 25, 2010 Author Share Posted October 25, 2010 Sweet, Thanks man. Been googling like mad and cant find anything that works correctly. This did it fine. Thanks very muchly! -G Link to comment https://forums.phpfreaks.com/topic/216763-insert-a-new-row-in-mysql-for-each-line-in-a-html-textarea/#findComment-1126137 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.