0

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>';

    ++$i;
}
2
Contributors
1
Reply
16
Views
6 Months
Discussion Span
Last Post by benanamen
0

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

Edited by benanamen

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.