/**
* Следующий пост
*
* @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);
$nextpost = mysqli_fetch_assoc($result);
if (!$nextpost) {
return first_post();
}
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);
$prevpost = mysqli_fetch_assoc($result);
if (!$prevpost) {
return last_post();
}
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;
}
preg_match( /<li>Артикул: <span>(.{3,24})<\/span><\/li>/ , $string);
$result2 = [
'2020-04-01' => ['users_id' => 19],
'2020-04-02' => ['users_id' => 133],
....
]
$result_days = [
'2019-04-27' => [
'id' => 1,
'off_id' => 133,
],
....
]
foreach ($result2 as $day => $i2) {
if (isset($result_days[$day])) {
echo "<td class='vihodnoy'>" . $i2['date'] . "</td>";
} else {
echo "<td class='obichniyDen'>" . $i2['date'] . "</td>";
}
}
foreach ($any as $result) {
foreach ($result as $i) {
if (isCheck($i, $name, $day)) {
print("<td>{$i['sub_hours']}</td>");
continue 2;
}
}
}
/**
* Проверка условия
*
* @param $itm
* @param $name
* @param $day
*
* @return bool
*/
function isCheck($itm, $name, $day)
{
if ($itm['name'] != $name) {
return false;
}
return ($itm['date'] == $day);
}
<input type="text" class="form-control" name="payment_methods[0][name]" value="">
<textarea class="form-control" name="payment_methods[0][description]" rows="5"></textarea>
<input type="text" class="form-control" name="payment_methods[1][name]" value="">
<textarea class="form-control" name="payment_methods[1][description]" rows="5"></textarea>
class Database
{
public function __construct($db_name, $db_user, $db_password)
{
try {
$this->pdo = new PDO("mysql:host=localhost;dbname=" . $db_name, $db_user, $db_password);
} catch (Exception $e) {
echo 'Sorry ' . $e->getMessage();
}
}
}
...........................
$db = new Database($config['db_name'], $config['db_user'], $config['db_password']);
127.0.0.1::xx
if ($mail->send()){
header("Location: https://www.google.com/");
} else {
// show html form
}
if ($mail->send()){
echo 'Thank! Your message has been sent!';
}
// show html form
query_posts(array('orderby' => 'title', 'order' => 'ASC', 'offset' => $offset))
$offset = {количество выводимых постов} * ( get_query_var('paged') - 1 )
$res = mail("your@mail.ru", "My Subject", "message");
if( $res ){
echo 'Сообщения отправляются';
} else {
echo 'Заблокирована отправка сообщений';
}