我有下表,名为“离开”:
ID | Employee | Numb1 | Numb2 | Numb3
1 | 4 | 12 | 2 | 10
2 | 4 | 10 | 3 | 7
3 | 4 | 7 | 2 | 5
当我更新第一行时,另一行中的Numb1和Numb3也会更新第一行的Numb3值。
我希望的输出就像我这张桌子一样: 这种情况是我将第一行的Numb 2 更改为 3
ID | Employee | Numb1 | Numb2 | Numb3
1 | 4 | 12 | 3 | 9
2 | 4 | 9 | 3 | 6
3 | 4 | 6 | 2 | 4
这是我的代码:
//Form Input
$amount = $_POST['amount'];
//Form Input END
$query_leave = mysql_query("SELECT
Numb1,
Numb2,
Numb3
FROM leave
WHERE
ID = '$id_edit'");
$data = mysql_fetch_array($query_leave);
$remains = $data[0] - $amount;
$query_update = mysql_query("UPDATE leave SET
ID = '$idkaryawan',
Numb2 = '$amount',
Numb3 = '$remains',
WHERE ID = '$id_edit'");
$query_leave2 = mysql_query("SELECT
Numb1,
Numb2,
Numb3
FROM leave
WHERE
ID <> '$id_edit' AND
Employee = 4");
$data2 = mysql_fetch_array($query_leave2);
$remains2 = $data2[0] - $data2[1];
$query_update2 = mysql_query("UPDATE leave SET
Numb1 = '$remains'
WHERE
ID <> '$id_edit' AND
Employee = 4");
使用上述代码时的输出是:
ID | Employee | Numb1 | Numb2 | Numb3
1 | 4 | 12 | 3 | 9
2 | 4 | 9 | 3 | 6
3 | 4 | 9 | 2 | 6
我的问题是我不知道如何循环它
目前,我正在使用PHP native开发此程序 非常感谢您的帮助