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

  • SEARCH
  • Home
  • 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 8579175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:33:22+00:00 2026-06-11T20:33:22+00:00

So I have a dynamic table on the page 2 where the user can

  • 0

So I have a dynamic table on the page 2 where the user can add as many entries as they want. After submitting the 3 page is getting all the info just fine. The problem is my for-loop iteration through the array is not working. Here’s the code:

for($i = 0; $i < sizeof($_POST["fname_new"]); $i++) {
    $fname_new = $_POST["fname_new"][i];
    $lname_new = $_POST["lname_new"][i];
    $phone_new = $_POST["phone_new"][i];
    $email_new = $_POST["email_new"][i];
    $ethnicity_new = $_POST["ethnicity_new"][i];
    $stmt = $link -> prepare("INSERT INTO Conference (`First Name`, `Last Name`, `Phone`, `Email`, `Ethnicity`) VALUES (:first_new, :last_new, :phone_new, :email_new, :ethnicity_new)");
    $stmt->bindParam(':first_new', $fname_new);
    $stmt->bindParam(':last_new', $lname_new);
    $stmt->bindParam(':phone_new', $phone_new);
    $stmt->bindParam(':email_new', $email_new);
    $stmt->bindParam(':ethnicity_new', $ethnicity_new);
    $stmt->execute();
}

So when I do

echo sizeof($_POST["fname_new"]);

It shows me the correct number, so if there were 3 rows that the user added on page 2 then the value echoed should be 3, which it is. When I do:

echo $_POST["fname_new"][0];

Then it appropriately gives the first name from the first row. I can replace 0 with any number, as long as it is in bounds, and it is correct. But for some reason when I do

echo $_POST["fname_new"][i];

It doesn’t print anything. I have no idea why this for loop isn’t working. Logically it is correct. Any ideas?

  • 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-06-11T20:33:23+00:00Added an answer on June 11, 2026 at 8:33 pm

    You forgot the $ to point to the variable i

    Try this:

    echo $_POST["fname_new"][$i];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic table on my page that a user can add rows/delete
What im doing is I have a dynamic table and creating rows which all
I have a DDL and Button which when clicked create a dynamic table; all
I have a problem with jquery and a dynamic table. I want a click
I have built a table from which I allow the user to add and
I have a dynamic range in an Excel sheet. DATA_TABLE =OFFSET(DATA!$B$3,0,0,COUNTA(DATA!$B:$B)-1,0) I want to
I have two table cells, with dynamic content. Table cell one works fine, when
Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
Using storyboard, I have a table view controller containing multiple dynamic prototype cells. One
I have dynamic web page with JS. There is a <textarea> and a Send

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.