<div class="main-content-inner">
<div class="row">
<div class="form-group">
<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>
</div>
<!-- table primary start -->
<div>
<?php
ini_set('error_reporting', E_ALL); // Включаем вывод всех ошибок
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
require_once('db.php');
if(isset($_POST['delivery_date']))
{
$form_date = $_POST['delivery_date'];
$SQL = "SELECT * FROM Users WHERE delivery_date='$form_date' AND delivery=1";
$result = mysqli_query($link, $SQL);
while ($res = mysqli_fetch_assoc($result)) {
echo '<div class="col-md-6 mt-5">
<div class="card">
<div class="card-body">
<h4 class="header-title">Заявка №<?=$res[\'id\']?></h4>
<ul class="list-group">
<li class="list-group-item"><?=$res[\'name\']?></li>
<li class="list-group-item"><?=$res[\'surname\']?></li>
<li class="list-group-item"><?=$res[\'second_name\']?></li>
<li class="list-group-item"><?=$res[\'phone\']?></li>
<li class="list-group-item"><?=$res[\'birth_date\']?></li>
<li class="list-group-item"><?=$res[\'birth_place\']?></li>
<li class="list-group-item"><?=$res[\'citizenship\']?></li>
<li class="list-group-item"><?=$res[\'doc\']?></li>
<li class="list-group-item"><?=$res[\'doc_id\']?></li>
<li class="list-group-item"><?=$res[\'doc_publish\']?></li>
<li class="list-group-item"><?=$res[\'doc_date\']?></li>
<li class="list-group-item"><?=$res[\'term\']?></li>
</ul>
</div>
</div>
</div>
</div> ';
}
}
?>
function get_printed_users()
{
global $link;
if (isset($_POST['delivery_date'])) {
$form_date = $_POST['delivery_date'];
$SQL = "SELECT * FROM Users WHERE delivery_date='$form_date' AND delivery=1";
$result = mysqli_query($link, $SQL);
$users = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $users;
} else {
$sql = "SELECT * FROM Users WHERE delivery = '1' ORDER BY id DESC LIMIT 25";
$result = mysqli_query($link, $sql);
$users = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $users;
}
}
<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>
<?php
$post = get_printed_users();
?>
<?php foreach ($post as $users): ?>
<li class="list-group-item">Имя: <?=htmlspecialchars($users['name'], ENT_QUOTES)?></li>
<li class="list-group-item">Фамилия: <?=htmlspecialchars($users['surname'], ENT_QUOTES)?></li>
<li class="list-group-item">Отчество: <?=htmlspecialchars($users['second_name'], ENT_QUOTES)?></li>
<li class="list-group-item">Телефон: <?=htmlspecialchars($users['phone'], ENT_QUOTES)?></li>
<?php endforeach; ?>
<?=$res['name']?>
<?echo $res['name'];?>
echo '...<li class="list-group-item">' . $res['name'] . '</li>...';
echo "...<li class="list-group-item">${res['name']}</li>...";
echo <<<HEREDOC
<div class="col-md-6 mt-5">
<div class="card">
<div class="card-body">
<h4 class="header-title">Заявка № {$res['id']}</h4>
<ul class="list-group">
<li class="list-group-item">{$res['name']}</li>
...
</ul>
</div>
</div>
</div>
</div>
HEREDOC;