how to automatically sum the scores that is being inputted in the textbox and display to the specific rows of textbox

this is my code for inputting score

while ($students = mysql_fetch_array($result)) {
    $total = $students['fld_quiz1'] + $students['fld_quiz2'] + $students['fld_quiz3'] + $students['fld_quiz4'] + $students['fld_quiz5'];

    echo '<tr>';
    echo "<td>{$students['id']}<input type='hidden' name='id[$i]' value='{$students['id']}' /></td>";
    echo "<td>{$students['fld_name']}</td>";
    echo "<td><input type='text' size='2' name='fld_quiz1[$i]' value='{$students['fld_quiz1']}' /></td>";
    echo "<td><input type='text' size='2' name='fld_quiz2[$i]' value='{$students['fld_quiz2']}' /></td>";
    echo "<td><input type='text' size='2' name='fld_quiz3[$i]' value='{$students['fld_quiz3']}' /></td>";
    echo "<td><input type='text' size='2' name='fld_quiz4[$i]' value='{$students['fld_quiz4']}' /></td>";
    echo "<td><input type='text' size='2' name='fld_quiz5[$i]' value='{$students['fld_quiz5']}' /></td>";

    echo "<td><input type='text' size='2' name='fld_midtotalquiz[$i]' value='".$total."' /></td>";

    echo '</tr>';


You have bigger problems to worry about. You are using obsolete, dangerous code that has been completetly removed from Php. You need to use PDO with Prepared Statements.
PDO Tutorial