function get_sum1()
{
global $link;
$sql = "SELECT *,SUM(manager_comment) as summa FROM users WHERE courier=1";
$result = mysqli_query($link, $sql);
$users = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $users;
}
$post=get_sum1();
foreach ($post as $users): ?><?=htmlspecialchars($users['summa'], ENT_QUOTES)?><?php endforeach ?></td>
<?php
$link=mysqli_connect("localhost","root","","test");
global $link;
function get_sum1()
{
global $link;
$sql = "SELECT *,SUM(sum) as summa FROM users WHERE courier=1";
$result = mysqli_query($link, $sql);
$users = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $users[0];
}
$users=get_sum1();
?>
<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['summa'], 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>
function get_sum1()
{
if (isset($_POST['delivery_date'])) {
global $link;
$delivery_date = $_POST['delivery_date'];
$sql = "SELECT SUM(manager_comment) 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[0]['summa'];
}
else
{
return false;
}
}
print get_sum1();