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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:49:43+00:00 2026-06-09T16:49:43+00:00

page_form.php echo ‘<div style=text-align:center;margin-left:25px;> <form action=grad.php method=post> <table width-100%> <tr><th style=padding:12px;>LETTER </th> <th style=padding:12px;>INTERVAL</th>

  • 0

page_form.php

echo '<div style="text-align:center;margin-left:25px;">
          <form action="grad.php" method="post">               
            <table width-"100%">
                  <tr><th style="padding:12px;">LETTER </th>
                      <th style="padding:12px;">INTERVAL</th>
                      <th style="padding:12px;">GT</th>
                  </tr>';
                 for($i=0;$i<=5;$i++)
                  {
                   echo '<tr><td style="padding:12px;"><input type="text" name="letter_'.$i.'"></td>
                             <td style="padding:12px;"><input type="text" name="interval'.$i.'"></td>
                             <td style="padding:12px;"><input type="text" name="gt'.$i.'"></td>
                         </tr>';
                  }
                  echo '<tr><td><input type="submit" name="submit" value="submit"></td></tr>';
           echo '</table>
         </form>
        </div>';

grad.php

$letter = $_POST['letter']; 
     $interval = $_POST['interval']; 
     $gt = $_POST['gt']; 
$s = mysql_query("INSERT INTO grad_table(letter,markint,gradepoint) VALUES('$letter',$interval,$gt) ");

I have given all the textboxes in a forloop. when I click on submit I need to get all the 5 textbox values, but right now iam getting only the 1st row.

Database Structure

   Field   Type          Collation      Attributes     Extra
     id    bigint(10)                    UNSIGNED     AUTO_INCREMENT
   letter  varchar(255)  utf+general_ci  
   markint  bigint(10)
     gt     bigint(10)
  • 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-09T16:49:45+00:00Added an answer on June 9, 2026 at 4:49 pm

    Your textbox names are not letter, as you’re using them – they are letter_0, letter_1, etc.

    Also, interval is a MySQL reserved-word and you’ll need to escape it using backticks: `interval`.

    To retrieve all of them, you can hardcode all of their names such as $letter1 = $_POST['letter_1'];, or you can do it in another loop:

    for ($i=0; $i<5; $i++) {
        $letter = $_POST['letter_' . $i]; 
        $interval = $_POST['interval' . $i]; 
        $gt = $_POST['gt' . $i]; 
        $s = mysql_query("INSERT INTO `grad_table` (`letter`, `interval`, `gt`) VALUES ('$letter',$interval,$gt)");
    }
    

    One big thing to note here is that you should really validate your user-input before inserting it into the database. First, you can use isset() before accessing the variables to make sure the user submitted the data. Second, you can use mysql_real_escape_string() to sanitize the string input and intval() for the integers:

    for ($i=0; $i<5; $i++) {
        // check that each field is posted
        if (!isset($_POST['letter_' . $i]) || !isset($_POST['interval' . $i]) || !isset($_POST['gt' . $i])) continue;
    
        // assign & sanitize
        $letter = mysql_real_escape_string($_POST['letter_' . $i]); 
        $interval = intval($_POST['interval' . $i]); 
        $gt = intval($_POST['gt' . $i]); 
        $s = mysql_query("INSERT INTO `grad_table` (`letter`, `interval`, `gt`) VALUES ('$letter',$interval,$gt) ");
    }
    

    Now, this doesn’t “validate” your data, but at least it will help prevent SQL injection and simply PHP errors.

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

Sidebar

Related Questions

I have a form in index.php <?php echo '<form action=update_act.php method=POST>'; echo '<input type=submit
I have a php form like this. <form name=form1 id=mainForm method=postenctype=multipart/form-data action=<?php echo $_SERVER['PHP_SELF'];?>>
With forms I've always used <form method=post action=<?php echo strip_tags($_SERVER['REQUEST_URI']); ?>> To get my
Here is my code: <form action=telecallerinfo.php?action=modify&id=<?php echo $id;?> method=post enctype=multipart/form-data> <table class=panel1> <tr> <td>Caller
<?php echo validation_errors(); ?> <?php echo form_open('verifylogin'); ?> <label for=username>Username:</label> <input type=text size=20 id=username
<script type=text/javascript> function removeLink() { document.getElementById(tab2).deleteRow(i); } </script> </head> <body> <form action=forth.php method=post> <table
I have the existing code: <form action=page.php?id=<?= $_GET['id'] ?> method=post> <fieldset> <p id=edit_name><label for=name>Page
I'm creating a simple registration page: <?php $firstName = $_POST['firstName']; ?> <form action=registration.php method=post
html in delete_define.php follows: <form action=delete_now.php onsubmit=my_funct();> <input type=submit name=my_submit class=my_submit value=submit/> </form> javascript
I have a php page called form.php. When you go to this page it

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.