Q:

Retrieve Loop textbox

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)

A:

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.

