Hello,
Got a code, need to insert a query for displaying links of posts in section. Category is 'blog', each post has it's 'id', and 'subject', which should be a name for link, such as "blog.php?p='id'".
Looking for help. Thank you in advance!
Stardar
<!doctype html>
<html lang="en">
<head>
</head>
<body class="base">
<div class="container">
<!-- PRZETWARZANIE WYNIKÓW Z BAZY -->
<?php
$total_pages = $link->query('SELECT * FROM news WHERE category="blog"')->num_rows;
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1;
$num_results_on_page = 1;
if ($stmt = $link->prepare('SELECT * FROM news WHERE category="blog" ORDER BY date DESC LIMIT ?,?')) {
$calc_page = ($page - 1) * $num_results_on_page;
$stmt->bind_param('ii', $calc_page, $num_results_on_page);
$stmt->execute();
$result = $stmt->get_result();
}
while ($row = $result->fetch_assoc()):
$text = $row['news'];
$text = str_replace('[video]','<div class="video-container">',$text);
$text = str_replace('[/video]','</div>',$text);
$text = str_replace('[media]','',$text);
$text = str_replace('[/media]','',$text);
$embera = new \Embera\Embera();
echo '<div class="container">
<div class="row">';
?>
<div class="col-sm-4">
/* here is a place for links to published posts */
</div>
<?php
echo '<div class="col-sm-8"><h3>'.$row['subject'].'</h3>';
echo '<div class="tresc embed-responsive">';
echo $embera->autoEmbed($text);
echo '</div></div>
</div>
</div>';
endwhile;
?>
<!-- KONIEC PRZETWARZANIA WYNIKÓW Z BAZY -->
<hr class="pagination_divider">
<center>
<!-- PAGINATION -->
<?php
if (ceil($total_pages / $num_results_on_page) > 0):
?>
<div class="sect_paginate"><ul class="pagination">
<?php
if ($page > 1):
?>
<li class="prev"><a href="blog.php?page=<?php echo $page-1 ?>">◂ WSTECZ</a></li>
<?php
endif;
?>
<li class="currentpage"><a href="blog.php?page=<?php echo $page ?>"><?php echo $page ?></a></li>
<?php
if ($page < ceil($total_pages / $num_results_on_page)):
?>
<li class="next"><a href="blog.php?page=<?php echo $page+1 ?>">DALEJ ▸</a></li>
<?php
endif;
?>
</ul></div>
<?php
endif;
$stmt->close();
?>
</center>
<!-- END OF PAGINATION -->
</div>
</body>
</html>