Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:46:53+00:00 2026-05-28T01:46:53+00:00

I need to know how to do the following using php coding please take

  • 0

I need to know how to do the following using php coding please

  1. take inserted text from a textarea
  2. split the content per line
  3. Insert each line into the database as its own row with own id number

Can anyone show me how to do this please?

thanks

EDIT________

THis is what I have tried so Far

$is_first = true;


foreach (explode('\n', $_POST['code']) as &$voucher) {

    if ($is_first) $is_first = false; else $query .= ', ';

    $query .= '(' . mysql_real_escape($voucher) . ')';
    mysql_query('INSERT INTO back_codes (`code_id`, `code`) VALUES (NULL, "$voucher")');
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:46:53+00:00Added an answer on May 28, 2026 at 1:46 am
    1. Refer to it using $_POST['field_name'], if it has been sent with POST request, like that:

      $textarea_value = $_POST['my_textarea'];
      
    2. You can split strings using explode(), like that:

      $lines = explode("\n", $textarea_value);
      
    3. Iterate through result of explode() and then insert rows one-by-one to the database.

      foreach ($lines as $line) {
          // $line here is a string
          // build a query based on it and execute it
      };
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PHP, jQuery, and JSON. Now I need to know how to
I need to know the default port settings for the following services SQL Server
I have the following setup, and I need to know how to persist state.
does anyone know of a good way of doing the following, I need to
I need to know, from within Powershell, if the current drive is a mapped
Using following Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} !/temp_page.php$ RewriteCond %{REQUEST_URI} !/thanks.php$ RewriteCond %{REMOTE_HOST}
I'd like to write a new website from scratch. I'll be using PHP for
I need to know what are the right order of the PHP learning steps,
I need to download from FTP over 5000 files being .html and .php files.
I need to obfuscate a certain area of an image using PHP and GD,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.