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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:56:53+00:00 2026-06-06T13:56:53+00:00

I am working on a PHP form that allows a user to add rows

  • 0

I am working on a PHP form that allows a user to add rows to a table and then submit the information using the form through email. I need to pass the variables into the email. I have tried using this:

$n = count($type);
$i = 0;
for ($i = 0; $i < $n; $i++){
    $e_classes = "______________________________________________ \r\n\n";
    $e_classes .=  "Class Type: {$type[$i]} \r\n";
    $e_classes .= "Number of Classes: {$nc[$i]} \r\n";
    $e_classes .= "Number of Students: {$sc[$i]} \r\n";
    $e_classes .= "______________________________________________ \r\n\n";
}

But when I get the email only the last one in the table is displaying. How would I get all of the added table rows to display? I can make everything work if I use ‘echo’, but I need to pass everything into a variable that I can use for an email.

  • 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-06T13:56:56+00:00Added an answer on June 6, 2026 at 1:56 pm

    Like this :

    $e_classes = '';
    $n = count($type);
    $i = 0;
    for ($i = 0; $i < $n; $i++){
        $e_classes .= "______________________________________________ \r\n\n";
        $e_classes .=  "Class Type: {$type[$i]} \r\n";
        $e_classes .= "Number of Classes: {$nc[$i]} \r\n";
        $e_classes .= "Number of Students: {$sc[$i]} \r\n";
        $e_classes .= "______________________________________________ \r\n\n";
    }
    

    Your first entry in your loop for the variable $e_classes was erasing what she had before because you used $e_classes = instead of $e_classes .=.

    This mean before each loop, your variable was reset with the value of your first row.

    You were doing this :

    $Var = '';
    for($i = 0, $i < n; $i++){
        $Var = 'a';
    }
    
    // Loop 1
    $Var = 'a';
    
    // Loop 2
    $Var = 'a';
    
    // Loop 3
    $Var = 'a';
    

    You wanted this :

    $Var = '';
    for($i = 0, $i < n; $i++){
        $Var .= 'a';
    }
    
    // Loop 1
    $Var = 'a';
    
    // Loop 2
    $Var = 'aa';
    
    // Loop 3
    $Var = 'aaa';
    

    The symbol = will overwrite the variable’s value with the new one.

    The symbol .= will append the value at the end of the variable.

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

Sidebar

Related Questions

I have an email attachment form that is working fine when the <form action=processingtheformfile.php>
I have a working PHP registration form that goes through $_POST[] requests to check
I have a form that allows a user to add an unlimited number of
I'm working on a PHP page that allows the user to reset their password.
I have simple php validation form that is halfway working. If you leave the
I am working on a php program that requires javascript on every form control.
I am working on a signup form, I am using PHP and on my
I'm working on a php(codeigniter) form that sends data to a PDF file when
I wrote a very simple web form that allows my user to view text
I am developing a web application that allows a user to add entries to

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.