/**
* Следующий пост
*
* @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']);
# запретить доступ ко всем файлам
<FilesMatch ".*">
Order allow,deny
Deny from all
</FilesMatch>
# Разрешить доступ только к файлам определенного расшерения
<FilesMatch "\.(jpg|png|gif)$|^$">
Order deny,allow
Allow from all
</FilesMatch>
# Выключим php
php_flag engine 0
# для все стремных файлов сделаем тип html
RemoveHandler .*
AddType "text/html" .php .cgi .pl .fcgi .fpl .phtml .shtml .php2 .php3 .php4 .php5 .asp .jsp