if(isset($_POST['delivery_date']))
{
$form_date = $_POST['delivery_date'];
printf($form_date);
$SQL = "SELECT * FROM Users WHERE delivery_date='$form_date' AND delivery=1";
$result = mysqli_query($link, $SQL);
while ($res = mysqli_fetch_assoc($result)) {
printf ("%s\n", $res["phone"]);
printf ("%s\n", $res["name"]);
printf ("%s\n", $res["surname"]);
printf ("%s\n", $res["second_name"]);
printf ("%s\n", $res["comment"]);
}
}
<?php
require_once 'functions.php';
?>
<?php
$post = get_delivery_users();
?>
<?php foreach ($post as $users): ?>
<div class="col-lg-12 mt-5">
<div class="card">
<div class="card-body">
<h4 class="header-title">Анкета №<?=$users['id']?> (<?=$users['order_date']?> <?=$users['order_time']?>)</h4>
<form>
<input type="hidden" name="form_id" value="<?=$users['id']?>">
<table class="table text-center">
<thead class="text-uppercase bg-success">
<tr class="text-white">
<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>
<tbody>
<tr>
<td><textarea class="form-control" type="text" name="phone" value="" id="example-text-input"><?=htmlspecialchars($users['phone'], ENT_QUOTES)?></textarea></td>
<td><textarea class="form-control" type="text" name="name" value="" id="example-text-input"><?=htmlspecialchars($users['surname'], ENT_QUOTES)?> <?=htmlspecialchars($users['name'], ENT_QUOTES)?> <?=htmlspecialchars($users['second_name'], ENT_QUOTES)?></textarea></td>
<td><div class="form-group">
<select name="delivery_adress" class="form-control">
<? foreach(get_delivery_addresses() as $delivery_address): ?>
<option <?if ($delivery_address == $users['delivery_adress']) echo ' selected'?>><?=htmlspecialchars($delivery_address, ENT_QUOTES)?></option>
<? endforeach;?>
</select>
</div></td>
<td><div class="form-group">
<input class="form-control" type="date" name="delivery_date" value="<?=htmlspecialchars(date('Y-m-d', strtotime($users['delivery_date'])), ENT_QUOTES)?>" id="example-date-input">
</div></td>
<td><div class="form-group">
<textarea class="form-control" type="text" name="delivery_time" value="" id="example-text-input"><?=htmlspecialchars($users['delivery_time'], ENT_QUOTES)?></textarea>
</div></td>
<td><textarea class="form-control" type="text" name="manager_comment" value="" id="example-text-input"><?=htmlspecialchars($users['manager_comment'], ENT_QUOTES)?></textarea></td>
<td><button type="submit" formmethod="post" name="save" formaction="save.php" class="btn btn-rounded btn-warning mb-3">Сохранить</button></td>
</tr>
</tbody>
</table>
</form>
<!-- table primary end -->
<?php endforeach; ?>
function get_delivery_users() {
global $link;
$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;
}
$SQL = "SELECT comment FROM Users WHERE delivery_date='$form_date' AND delivery='1'";
$result = mysqli_query($link, $SQL);
while ($res = mysqli_fetch_assoc($result)) {
printf ("%s\n", $res["comment"]);
}
<?php
//Параметры подключения в БД
$host = "localhost"; //имя хоста
$database = "test1"; //имя базы
$user = "root"; //пользователь
$password = ""; //пароль
$dbtable = "Users"; //таблица
$link = mysqli_connect($host, $user, $password, $database)
or die("Ошибка " . mysqli_error($link));
?>
<?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 $dbtable WHERE delivery_date='$form_date' AND delivery='1' ORDER BY id DESC";
$result = mysqli_query($link, $SQL);
var_dump($result); //смотрим приходит ли что-то по запросу
while ($res = mysqli_fetch_assoc($result)) {
printf ("%s\n", $res["delivery_date"]);
}
}
?>
У меня получилось! :)
Я просто вставил этот php-код прямо на страницу и всё заработало :)
Может выложите в ответы свой вариант решения, чтобы я отметил его как верное решение?