/**
* Следующий пост
*
* @param $post_id
*
* @return string[]|null
*/
function next_post($post_id)
{
global $link;
$sql = "SELECT * FROM projects WHERE id > " . $post_id . " ORDER BY id ASC LIMIT 1";
$result = mysqli_query($link, $sql);
if (!$result) {
return null;
}
$nextpost = mysqli_fetch_assoc($result);
return $nextpost;
}
/**
* Предыдущий пост
*
* @param $post_id
*
* @return string[]|null
*/
function prev_post($post_id)
{
global $link;
$sql = "SELECT * FROM projects WHERE id < " . $post_id . " ORDER BY id DESC LIMIT 1";
$result = mysqli_query($link, $sql);
if (!$result) {
return null;
}
$prevpost = mysqli_fetch_assoc($result);
return $prevpost;
}
<div class="paginator">
<?php if (!is_null(prev_post())): ?>
<a href="#" class="prev"></a>
<?php endif; ?>
<?php if (!is_null(next_post())): ?>
<a href="#" class="next"></a>
<?php endif; ?>
</div>
<?php
$a = 5;
$b = 10;
function summa()
{
$summan = $GLOBALS['a'] + $GLOBALS['b'];
return $summan;
}
var_dump(summa());
/**
* Следующий пост
*
* @param $post_id
*
* @return string[]|null
*/
function next_post($post_id)
{
global $link;
$sql = "SELECT * FROM projects WHERE id > " . $post_id . " ORDER BY id ASC LIMIT 1";
$result = mysqli_query($link, $sql);
if (!$result) {
return first_post();
}
$nextpost = mysqli_fetch_assoc($result);
return $nextpost;
}
/**
* Предыдущий пост
*
* @param $post_id
*
* @return string[]|null
*/
function prev_post($post_id)
{
global $link;
$sql = "SELECT * FROM projects WHERE id < " . $post_id . " ORDER BY id DESC LIMIT 1";
$result = mysqli_query($link, $sql);
if (!$result) {
return last_post();
}
$prevpost = mysqli_fetch_assoc($result);
return $prevpost;
}
/**
* Первый пост
*
* @return string[]|null
*/
function first_post()
{
global $link;
$sql = "SELECT * FROM projects WHERE ORDER BY id ASC LIMIT 1";
$result = mysqli_query($link, $sql);
$post = mysqli_fetch_assoc($result);
return $post;
}
/**
* Последний пост
*
* @return string[]|null
*/
function last_post()
{
global $link;
$sql = "SELECT * FROM projects WHERE ORDER BY id DESC LIMIT 1";
$result = mysqli_query($link, $sql);
$post = mysqli_fetch_assoc($result);
return $post;
}
$result2 = [
['users_id' => 19, 'day' => '2020-04-01'],
['users_id' => 133, 'day' => '2020-04-02'],
];
$result2_with_key = [];
foreach ($result2 as $item) {
$result2_with_key[$item['day']] = $item;
}
jQuery('.plus').click(function () {
var num = jQuery('.js-form-line').size();
jQuery('#information_json_plus').append(
'<tr class="js-form-line">' +
'<td>' +
'<input type="text" class="form-control" name="payment[' + num + '][id]" value="' + num + '">' +
'<input type="text" class="form-control" name="payment[' + num + '][name]" value="">' +
'</td>' +
'<td><textarea class="form-control" name="payment[' + num + '][description]" rows="5"></textarea></td>' +
'<td><span class="btn btn-danger minu<code lang="php">
</code>s pull-right">–</span></td>' +
'<td><span class="btn btn-success plus pull-right">+</span></td>' +
'</tr>'
);
});
json_encode($_POST['payment']);
var num = jQuery('.js-form-line').length;
jQuery('.plus').click(function () {
var num = jQuery('.js-form-line').size();
jQuery('#information_json_plus').append(
'<tr class="js-form-line">' +
'<td><input type="text" class="form-control" name="payment[' + num + '][name]" value=""></td>' +
'<td><textarea class="form-control" name="payment[' + num + '][description]" rows="5"></textarea></td>' +
'<td><span class="btn btn-danger minus pull-right">–</span></td>' +
'<td><span class="btn btn-success plus pull-right">+</span></td>' +
'</tr>'
);
});
$new_file_name = md5(time() . $_FILES['inputfile']['name']);
CREATE TABLE relation (
user_id BIGINT(20) NOT NULL,
city_id BIGINT(20) NOT NULL,
PRIMARY KEY (user_id, city_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;;
в
event(new SocketMessage($tag));
вы передаёте объект До изменения его свойств, так и надо?