public static function renderPaginator($total, $current, $indent = 3)
{
$start = 1 + $indent;
$end = $total - $indent;
$mid_start = $current - $indent;
$mid_end = $current + $indent;
?>
<nav style="margin: 0 auto;">
<ul class="pagination">
<?
$skip1 = ($current < $start || $current > $end);
if ($current == 1) { // previous
?><li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">«</span></a></li><?
} else {
?><li><a href="?page=<?=($current-1)?>" aria-label="Previous"><span aria-hidden="true">«</span></a></li><?
}
for ($p = 1; $p <= $total; $p++) { // each page
if ($p == $current) {
?>
<li class="active"><a href="#"><?=$p?> <span class="sr-only">(текущая)</a></li><?
} else {
if($p < $start
|| ($p > $mid_start && $p < $mid_end)
|| $p > $end
|| ($p == $start && $p == $mid_start)
|| ($p == $end && $p == $mid_end)
) {
?>
<li><a href="?page=<?=$p?>"><?=$p?></a></li><?
} elseif($p == $start || $p == $end) {
?>
<li class="disabled"><a href="#">...</a></li><?
}
}
}
if ($current == $total) { // next
?><li class="disabled"><a href="#" aria-label="Next"><span aria-hidden="true">»</span></a></li><?
} else {
?><li><a href="?page=<?=($current-1)?>" aria-label="Next"><span aria-hidden="true">»</span></a></li><?
}
?>
</ul>
</nav>
<?
}
1 -2 - 3 ... 39 - 40 - 41 - 42 - 43 -44 - 45 ... 98 - 99 -100
function array2Menu($items, $level = 0) {
$result = '';
foreach ($items as $item) {
$class= ""; // впишите свои классы в зависимости от $level
$result .= "<li class=\"$class\"><a href=\"{$item['code']}\">{$item['name']}</a>";
if (!empty($item['childs'])) {
$result .= array2Menu($item['childs'], $level + 1);
}
$result .= "</li>";
}
return "<ul class=\"level$level\">$result</ul>"; // тоже впишите свои классы в зависимости от $level
}
$(window).on('resize', myResizer);
$(document).on('ready', myResizer);
function myResizer(){
// ...
}
foreach ($products as $productJSON) {
$product = json_decode($productJSON, true);
?>
<div class="product">
<h2><?=$product['name']?><h2>
<p><?=$product['description']?></p>
<img src="/images/products/<?=$product['Preview_image']?>">
</div>
<?}
$response = [
'status': 'error', // или 'ok', тогда другие поля не указываются
// дальше статус по каждому из полей с ошибкой
'email': 'already_used', // или 'invalid' или еще какие-то ваши статусы
'phone': 'invalid'
];
return json_encode($response, $flags);
$ff['money'] = intval($ff['money']) - intval($ff1['money']);
let data = [
{id: 1, serial: "Blood.Drive", season: 1},
{id: 2, serial: "Blood.Drive", season: 1},
{id: 3, serial: "Foo.Bar", season: 1},
{id: 4, serial: "HelloWorld", season: 1},
]
let unique = data.reduce((acc,elem)=>acc.add(elem.serial), new Set())
console.log(unique)
https://jsfiddle.net/9Lunhds9/ new FormData(form);
А где ее записать тоВ командной строке вашего сервера, очевидно. Ну или в скрипте в вашем случае.
$('.btn-del').on('click', function(){ // на элементы с классом .btn-del вешается обработчик
$(this).closest('tr').remove(); // который находит ближаейший родительский tr и удаляет.
})
while ($curr_time < $target_time) {
usleep(10000); // 0.01 sec или какая вам там точность нужна.
}
var Go = {
Login: function(){
$("#login").submit(); // но у вас же нет элемента с id=login
}
}
и вообще, зачем это всё?<a href="#" onclick="this.closest('form').submit(); return false;">foo</a>