PHP Useless,
важно правильно прописать классы как в примере в каждой таблице ...
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<table width="400" class="qrup" >
<thead>
<tr>
<th>Fənnlər</th>
<th>D</th>
<th>Y</th>
<th>FB</th>
</tr>
</thead>
<tbody>
<tr class="study">
<td>Ana dili</td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study">
<td>Riyaziyyat</td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study">
<td>Fizika</td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr>
<td colspan="2" ></td>
<td >Sizin Balınız</td>
<td class="result"></td>
</tr>
</tbody>
</table>
<table width="400" class="qrup" >
<thead>
<tr>
<th>Fənnlər</th>
<th>D</th>
<th>D-A</th>
<th>Y</th>
<th>FB</th>
</tr>
</thead>
<tbody>
<tr class="study">
<td>Ana dili</td>
<td><input name=""></td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study">
<td>Riyaziyyat</td>
<td><input name=""></td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study">
<td>Fizika</td>
<td><input name=""></td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr>
<td colspan="3" ></td>
<td>Sizin Balınız</td>
<td class="result"></td>
</tr>
</tbody>
</table>
<script>
var fb = [function(a, b) { //формулы для каждой таблицы по порядку
return 1 * (4 * a - b) //k1 = 1
}, function(a, b, c) {
return 2 * (4 * a - b + c) //k1 = 2
}],
total = function(a) {
return a.reduce(function(a, b) {
return a + b
}, 0)
};
[].forEach.call(document.querySelectorAll(".qrup"), function(table, i) {
var sum = [],
result = table.querySelector(".result");
[].forEach.call(table.querySelectorAll(".study"), function(tr, k) {
var temp = [],
interim = tr.querySelector(".interim");
sum[k] = 0;
[].forEach.call(tr.querySelectorAll("input"), function(input, j) {
temp[j] = 0;
input.addEventListener("input", function() {
var val = +input.value || 0;
input.value = temp[j] = val;
sum[k] = fb[i].apply(null, temp);
interim.innerHTML = sum[k];
result.innerHTML = total(sum)
})
})
})
});
</script>
</body>
</html>