<form method="post" name="delivery_date" action="">
<input class="form-control" type="date" name="delivery_date" value="" id="example-date-input"> <button type="submit" class="btn btn-primary btn-xs mb-3">Найти</button>
</form>
<tbody>
<tr>
<td><?php
$post = get_1();?>
<? foreach($post as $users)?><h4>Курьер 1: <?=htmlspecialchars($users['courier_name'], ENT_QUOTES)?></h4></td>
</tr>
</tbody>
<table class="table text-center">
<thead class="text-uppercase">
<tr>
<th scope="col">ID</th>
<th scope="col">Метро</th>
<th scope="col">Время</th>
<th scope="col">ФИО</th>
<th scope="col">Сумма</th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
</thead>
<?php
$post = get_cargo_users1();
foreach ($post as $users):
$colorClass = '';
switch($users['delivery_status']){
case 1:
$colorClass = 'alert-success';
break;
case 2:
$colorClass = 'alert-danger';
break;
case 3:
$colorClass = 'alert-warning';
break;
}?>
<tbody>
<tr>
<td><div class="alert <?=$colorClass?>" role="alert"><?=$users['id']?></div></td>
<input type="hidden" name="form_id" value="<?=$users['id']?>">
<td><div class="alert <?=$colorClass?>" role="alert"><?=htmlspecialchars($users['delivery_adress'], ENT_QUOTES)?></div></td>
<td><div class="alert <?=$colorClass?>" role="alert"><?=htmlspecialchars($users['delivery_time'], ENT_QUOTES)?></div></td>
<td><div class="alert <?=$colorClass?>" role="alert"><?=htmlspecialchars($users['surname'], ENT_QUOTES)?> <?=htmlspecialchars($users['name'], ENT_QUOTES)?> <?=htmlspecialchars($users['second_name'], ENT_QUOTES)?></div></td>
<td><div class="alert <?=$colorClass?>" role="alert"><?=htmlspecialchars($users['sum'], ENT_QUOTES)?></div></td>
<td><button type="button" name="delivery_status" class="btn btn-xs btn-success mb-3" value="1">Отдал</button></td>
<td><button type="button" name="delivery_status" class="btn btn-xs btn-danger mb-3" value="2">Отказ</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>
<?php endforeach ?>
</table>
$('button[name="delivery_status"]').on('click', function() {
let $btn = $(this);
let id = $btn.closest('tr').find('input[name="form_id"]').val(); // получаем id
// формируем данные
let data = {
form_data: id,
delivery_status: $btn.val()
};
$.ajax({
type: "POST",
url: "dost.php",
data: data,
success: function() {
alert('Load was performed.');
}
}).done(function() {
alert("Данные сохранены");
});
return false;
});