Skip to content
Advertisement

It’s only inserting the last value from a textarea

I’m placing a bunch of emails into a html textarea form. I need to insert the email addresses into my database so I’m using INSERT INTO but for some reason it’s only inserting the last value (email). I’m separating the emails with a line break when placing them into the textarea. (see image below)

screenshot of textarea containing email addresses

Also, is it ok to put a sql query inside a loop?

Example Emails

  • toku***@att.net
  • fros***@gmail.com
  • jpfl***@sbcglobal.net
  • besc***@msn.com
  • pgot***@icloud.com
  • seth***@outlook.com 🔴 This is the only email that gets recorded to the database!

Code:

JavaScript

Advertisement

Answer

if you use textarea then you can do the following:

First Solution:

JavaScript

Second Solution:

JavaScript

Third Solution:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement