$(document).on('click', 'button[name="delete_item"]', function() {
event.preventDefault();
let $row = $(this).closest('tr');
let data = $row.find('input').serialize();
$.ajax({
type: "POST",
url: "delete_item.php",
data: data,
success: function(html){
$("#table_ajax").load('table.php');
$('#order')[0].reset();
}
});
return false;
});
$ch = curl_init('https://api.yandex.mightycall.ru/api/v3/auth/token');
$body = 'grant_type=client_credentials&
client_id=***&
client_secret=***';
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type: application/x-www-form-urlencoded',
'x-api-key: ***',
));
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
<select name="delivery_adress">
<? foreach(get_delivery_addresses() as $delivery_address): ?>
<option <?if ($delivery_address == $delivery_adresses['delivery_adress']) echo ' selected'?>>
<=htmlspecialchars($delivery_address, ENT_QUOTES)?>
</option>
<? endforeach;?>
</select>
function get_delivery_addresses() {
$sql = "SELECT delivery_adress FROM Subway ORDER BY id DESC";
$result = mysqli_query($link, $sql);
$delivery_adresses = mysqli_fetch_all($result, MYSQLI_ASSOC);
retur $delivery_adresses;
}
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; ?>
<?php
//Параметры подключения в БД
$host = "localhost"; //имя хоста
$database = "base"; //имя базы
$user = "root"; //пользователь
$password = "pass"; //пароль
$dbtable = "table"; //таблица
$link = mysqli_connect($host, $user, $password, $database)
or die("Ошибка " . mysqli_error($link));
?>
require_once('db.php');
function search_users() { //объявляем функцию
$query = strip_tags(trim($_POST['query'])); //принимаем данные из формы поиска
if (preg_match('/[0-9]/', $query)) { //задаём условия для поиска (в данном случае совпадения номера или строки
$sql = "SELECT * FROM Users WHERE phone LIKE '%$query%' ORDER BY id DESC"; //делаем выборку в базе по телефону
}
else {
$sql = "SELECT * FROM Users WHERE surname LIKE '%$query%' ORDER BY id DESC"; //делаем выборку в базе по фамилии
}
global $link;
$result = mysqli_query($link, $sql);
$users = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $users; //выводим результат
}