$search_articles = mysqli_prepare($connect, "SELECT post_id, post_title, post_description, post_keywords, post_author, post_date, post_image, post_content, post_link FROM post WHERE post_title LIKE ?");
mysqli_stmt_bind_param($search_articles, '%s%', $search);
function get_post_old($param_name_article)
{
global $connect;
$post_old = mysqli_prepare($connect, "SELECT post_id, post_title, post_description, post_keywords, post_author, post_date, post_image, post_content, post_link FROM post WHERE post_link = ? LIMIT 1");
@mysqli_stmt_bind_param($post_old, "s", $param_name_article);
if(!$post_old)
{
echo 'Ошибка таблицы!';
//запись в логи
exit();
}
if(!@mysqli_execute($post_old))
{
echo 'Ошибка запроса!';
//запись в логи
exit();
}
mysqli_stmt_bind_result($post_old, $post_id, $post_title, $post_description, $post_keywords, $post_author, $post_date, $post_image, $post_content, $post_link);
while(mysqli_stmt_fetch($post_old))
{
$name_post_old = array
(
'post_id' => $post_id,
'post_title' => $post_title,
'post_description' => $post_description,
'post_keywords' => $post_keywords,
'post_author' => $post_author,
'post_date' => $post_date,
'post_image' => $post_image,
'post_content' => $post_content,
'post_link' => $post_link
);
$name_post_old['manth'] = mb_substr($name_post_old['post_date'], 5, 2);
$name_post_old['manth'] = manth($name_post_old['manth']);
$name_post_old['years'] = mb_substr($name_post_old['post_date'], 0, 4);
$name_post_old['day'] = ltrim(mb_substr($name_post_old['post_date'], 8, 2), '0');
$res_post_old[] = $name_post_old;
}
mysqli_stmt_close($post_old);
return $res_post_old;
}
//model
function get_post_old($param_name_article)
{
global $connect;
$post_old = mysqli_prepare($connect, "SELECT post_id, post_title, post_description, post_keywords, post_author, post_date, post_image, post_content, post_link FROM post WHERE post_link = ? LIMIT 1");
@mysqli_stmt_bind_param($post_old, "s", $param_name_article);
if(!$post_old)
{
echo 'Ошибка таблицы!';
//запись в логи
exit();
}
if(!@mysqli_execute($post_old))
{
echo 'Ошибка запроса!';
//запись в логи
exit();
}
mysqli_stmt_bind_result($post_old, $post_id, $post_title, $post_description, $post_keywords, $post_author, $post_date, $post_image, $post_content, $post_link);
while(mysqli_stmt_fetch($post_old))
{
$name_post_old = array
(
'post_id' => $post_id,
'post_title' => $post_title,
'post_description' => $post_description,
'post_keywords' => $post_keywords,
'post_author' => $post_author,
'post_date' => $post_date,
'post_image' => $post_image,
'post_content' => $post_content,
'post_link' => $post_link
);
$name_post_old['manth'] = mb_substr($name_post_old['post_date'], 5, 2);
$name_post_old['manth'] = manth($name_post_old['manth']);
$name_post_old['years'] = mb_substr($name_post_old['post_date'], 0, 4);
$name_post_old['day'] = ltrim(mb_substr($name_post_old['post_date'], 8, 2), '0');
$res_post_old[] = $name_post_old;
}
mysqli_stmt_close($post_old);
return $res_post_old;
}
//views
if($post_old)
{
foreach($post_old as $name)
{
echo '<h2>
<a href="'.PATH.$ref.'">'.$name['post_title'].'</a>
</h2>
<p class="lead">
by <a href="'.PATH.'">'.$name['post_author'].'</a>
</p>
<p><span class="glyphicon glyphicon-time"></span> Опубликовано '.$name['day'].' '.$name['manth'].' '.$name['years'].'</p>
<hr>
<img class="img-responsive" src="'.$name['post_image'].'" alt="">
<hr>
<p>'.$name['post_content'].'</p>
<a class="btn btn-primary" href="'.PATH.$ref.'"><span class="glyphicon glyphicon-chevron-left"></span> Назад</a>
<hr>';
}
}
//controller
<?php
defined('NAMESITE') or die('Access denied');
ob_start();
session_start();
require_once MODEL;
$top_menu = get_top_menu();
$sidebar_category = get_sidebar_category();
$post_all = get_post_all();
$go_search = htmlspecialchars($_POST['go_search']);
if(isset($go_search))
{
$search = htmlspecialchars($_POST['search']);
if(empty($search))
{
$messages = 'Вы не ввели поисковой запрос!';
}
elseif(mb_strlen($search) >= 32)
{
$messages = 'Слишком большой поисковой запрос!';
}
else
{
$search_articles = get_search_articles($search);
if($search_articles)
{
foreach ($search_articles as $num) {
$num = $num['num'];
}
}
if ($num > 0)
{
$messages = "По вошему запросу найдено: $search";
}
else
{
$messages = "$search Не найдено!";
}
}
}
$url_address = htmlspecialchars($_SERVER['REQUEST_URI']);
$path = htmlspecialchars($_SERVER['PHP_SELF']);
$path = mb_substr($path, 0, strpos($path, 'index.php'));
if($path === PATH)
{
$request_url = mb_substr($url_address, strlen(PATH));
$url = explode('/', rtrim($request_url, '/'));
$controller = $url[0];
if($top_menu || $sidebar_category || $post_all)
{
foreach ($top_menu as $name_m)
{
$name[] = $name_m['link_category'];
}
foreach ($sidebar_category as $namesis)
{
$names[] = $namesis['link_cat'];
}
foreach ($post_all as $all)
{
$art[] = $all['post_id'];
$arti[] = $all['post_link'];
}
if(empty($controller))
{
$title = 'Главная';
$ref = 'articles';
require_once VIEW.'index.php';
}
elseif($controller === 'search')
{
$title = 'Поиск';
$message_s = $messages;
$ref = $controller;
if($ref === 'search')
{
$ref = 'articles';
}
require_once VIEW.'search.php';
}
elseif(in_array($controller, $names) || in_array($controller, $name) || (in_array($controller, $arti) && !empty($url[1])))
{
$key = array();
$value = array();
if(!empty($url[1]))
{
$param_name_article = $url[1];
$post_old = get_post_old($param_name_article);
if(in_array($param_name_article, $arti))
{
$ref = $controller;
require_once VIEW.'article.php';
}
else
{
echo '404';
}
}
else
{
$title = 'Статьи';
$ref = $controller;
if(in_array($ref, $names))
{
$post_cat = get_post_category($ref);
require_once VIEW.'article_cat.php';
}
else
{
require_once VIEW.'index.php';
}
}
}
else
{
echo '404';
exit();
}
}
}
<?php
echo '<p>Hi Bro</p>';//Этим способом сейчас пользуюсь(
<p><?php echo Hi Bro; ?><p>
<p><?= Hi Bro; ?><p>
<?php
echo '<p>';?>
Hi Bro
<?php echo '</p>';?>
import {square as sqrt} from './sqrt';
const sumOfSquares = (a, b) => {
return 1 / 2 * (a * sqrt(b * b - a * a / 4));
};
sumOfSquares(3, 2); //Реализуйте функцию которая находит площадь равнобедренного треугольника может параметры не подходят?
//export default square => Math.sqrt(num);
const square = (num) => {
return Math.sqrt(num);
};
export default square;