$SQL = "UPDATE Users SET phone='$phone', sum='$sum', name='$name', surname='$surname', second_name='$second_name', manager_comment='$manager_comment', delivery_adress='$delivery_adress', delivery_time='$delivery_time', delivery_date='$delivery_date', courier='$courier' WHERE id='$form_id'";
<td><?php
$post = get_sum1();
foreach ($post as $users): ?><?=htmlspecialchars($users['summa'], ENT_QUOTES)?><?php endforeach ?></td>
<?php
$post = get_cargo_users1();
?>
<?php foreach ($post as $users): ?>
<form method="post" action="dost.php">
<tbody>
<tr>
<td><?=$users['id']?></td>
<td><?=htmlspecialchars($users['delivery_adress'], ENT_QUOTES)?></td>
<td><?=htmlspecialchars($users['delivery_time'], ENT_QUOTES)?></td>
<td><?=htmlspecialchars($users['surname'], ENT_QUOTES)?> <?=htmlspecialchars($users['name'], ENT_QUOTES)?> <?=htmlspecialchars($users['second_name'], ENT_QUOTES)?></td>
<td><?=htmlspecialchars($users['sum'], ENT_QUOTES)?></td>
<td><button type="submit" formmethod="post" name="delivered" class="btn btn-xs btn-success mb-3" id="delivered">Отдал</button></td>
<td><button type="submit" formmethod="post" name="undelivered" class="btn btn-xs btn-danger mb-3">Отказ</button></td>
<td><button type="button" formmethod="post" name="delivery" class="btn btn-xs btn-warning mb-3" data-toggle="modal" data-target="#exampleModalLong">Перенос</button></td>
</tr>
</tbody>
</form>
<?php endforeach ?>
as summaв вашем коде.
function get_sum_1()
{
global $link;
if (isset($_POST['delivery_date'])) {
$delivery_date = $_POST['delivery_date'];
$sql = "SELECT SUM(sum) as summa FROM Users WHERE courier=1 AND delivery_date='$delivery_date' AND delivery_status=1";
$result = mysqli_query($link, $sql);
$users = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $users;
}
}
if(isset($_POST['undelivered']))
{
$form_id = (int)$_POST['form_id'];
$SQL = "UPDATE Users SET delivery_status=2 WHERE id='$form_id'";
$result = mysqli_query($link, $SQL);
if ($result) {
var_dump($SQL);
}
else {
printf("Ошибка: %s\n", mysqli_error($link));
}
}
if(isset($_POST['delivered']))
{
$form_id = (int)$_POST['form_id'];
$SQL = "UPDATE Users SET delivery_status=1 WHERE id='$form_id'";
$result = mysqli_query($link, $SQL);
if ($result) {
var_dump($SQL);
}
else {
printf("Ошибка: %s\n", mysqli_error($link));
}
}