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 6758961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:52:19+00:00 2026-05-26T13:52:19+00:00

I tried to insert multiple rows from one form using checkboxes, include take values

  • 0

I tried to insert multiple rows from one form using checkboxes, include take values from input box, all of them has the structure:

<input id="Valor" type="text" name="Valor[]" value="<?php echo $row2["Valor"];  ?>" />

and the checkbox is like:

<input type="checkbox" name="Pago[]" id="Pago" value="<?php echo $row2["IdSolicitudTarjeta"]; ?>" />

But when I’ll send the form at ‘insertmultiple.php’ I use the following code but only shows 2 results. Don’t matter how many times I tried show the rest, don’t works:

foreach($_POST['Pago'] as key => $val) {
$Producto = $_POST['Producto'][$key];
$FormaPago = $_POST['FormaPago'][$key];
$FechaConsignacion = $_POST['FechaConsignacion'][$key];
$Valor = $_POST['Valor'][$key];
$Detalle = $_POST['Detalle'][$key];
$FechaRegistrar = $_POST['FechaRegistrar'][$key];

echo $Pago."&nbsp;--&nbsp;".$FechaConsignacion."&nbsp;--&nbsp;".$Producto."&nbsp;--&nbsp;";
echo $FormaPago."&nbsp;--&nbsp;".$Valor."&nbsp;--&nbsp;".$Detalle."&nbsp;--&nbsp;";
echo $FechaRegistrar."<br>";

}

please help! 🙁

  • 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-26T13:52:19+00:00Added an answer on May 26, 2026 at 1:52 pm

    First thing:
    not key but $key

    foreach($_POST['Pago'] as $key => $val) {
    

    I dont see any SQL code though.

    ADDENDUM

    Hm… it seems like a really messy way to insert things into database. As Cyclone noticed you do not purify your input prior to inserting the date. This is wrong but its a story for another post :p

    Besides consider one thing:

    Are you sure you want to use

    $Producto = $_POST['Producto'][$key];
    

    and not:

    $Producto = $_POST['Producto'][$val];
    

    You seem to store some id in those checkboxes… otherwise you may have a scenario like:

    1  [x]
    2  [ ]
    3  [ ]
    4  [x]
    

    So I blieve that $_POST['Pago'] will have only 2 fields 1 and 4… but their key will be 1 and 2 as inactive checkboxes will not have value and will not end-up in the array. I may be wrong though… shame to admit I do not remember how it works precisely O.o

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert multiple selected values into database in listbox. I am using
Here is simple form contain multiple checkboxes options and textarea input: <form method=post name=form1
I was wondering how you can insert multiple rows into a MySQL database using
i'm trying to insert multiple data using a query, i've tried the implode function,
I want to insert multiple values in a table where the value in one
I have a form that has multiple categories. They are separated by checkboxes, so
I created MVC ASP.Net Web application and tried insert Thai language data to SQL
I'm going crazy today. I just tried to insert a new record and it
I tried running the following statement: INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION) SELECT (a.number,
Tried to map it from Preferences -> Settings -> Keyboard, but the key combo

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.