Вывод строк по id на статьи
Здраствуйте! Начал изучать PHP и RedBean PHP. Прошу помощы у вас. Буду благодарен за помощь! Мне нужно вывести название новости, которое равно id новости. Текст новости, который равен id новости. Вывод статьи на главной:
$query = R::findAll('posts', ' ORDER BY id DESC');
foreach ($query as $posts){
echo ' <div class="col-news">
<img src="img/photo.jpg" alt="">
<div class="foreword">
<a href="/post.php?post_id='.$posts['id'].'">'.mb_substr($posts['title'], 0, 45).'</a>
<p>'.mb_substr($posts['content'], 0, 340), '...'.'</p>
</div>
</div>';
}
Сам пост:
$query = R::find('posts');
foreach ($query as $posts){
echo ' <section class="container-fluid section-post">
<div class="header-menu">
<a href="index.php" class="logo">Wires</a>
<div class="header-button">
<a href="index.php" class="button" style="margin: 0 30px 0 30px;">На главную</a>
<a href="signup.php" class="button login">Войти / Регистрация</a>
<a href="logout.php" class="button logout">Выйти</a>
</div>
</div>
<div class="content-post active">
<h1 class="title-content">'.$posts['title'].'</h1>
<img src="img/photo.jpg" alt="" class="img-posts">
<p>'.$posts['content'].'</p>
</div>
</section>'
;
}