<?php
include 'db_connect.php';
mysqli_query ($db, "UPDATE portfolio SET views = views + 1");
?>
<?php
include 'db_connect.php';
mysqli_query ($db, "UPDATE portfolio SET views = views + 1 WHERE id = $id");
?>
$(".views").click (function (
$.ajax({
type: "post",
url: "includes/ajax.php"
});
));
<div class="gallery_block">
<a class="views" href="<?php echo $imageURL; ?>">
<img src="<?php echo $imageURL; ?>" />
</a>
</div>
<div class="portfolio-block">
<?php $portfolio = get_portfolio_all();
foreach ($portfolio as $portfolio): ?>
<div id="page-block" class="hide-show-info">
<h2 id="title-page"><?php echo $portfolio['portfolio_title']; ?></h2>
<p id="text-product"><?php echo $portfolio['portfolio_text']; ?></p>
<div class="flyout hidden">
<div class="button-product">
<a href="<?php echo $portfolio['portfolio_link']; ?>" target="_blank"><?php echo $portfolio['portfolio_button_text']; ?></a>
</div>
</div>
<div id="bg-mask" class="pic">
<img id="content-img" class="grayscale-mask" src="<?php echo 'admin/portfolio/upload/'.$portfolio['image']; ?>" alt="Portfolio">
</div>
</div>
<?php endforeach; ?>
</div>
function get_portfolio_all($offset = 0, $limit = 4) {
global $connection;
$portfolio = $connection->prepare("SELECT * FROM portfolio ORDER BY id DESC LIMIT ?,?");
$portfolio->execute([$offset, $limit]);
return $portfolio->fetchAll(PDO::FETCH_ASSOC);
}
https://prnt.sc/p82l12
<?php
// Include the database configuration file
include_once 'includes/db_connect.php';
// Get images from the database
$query = $db->query("SELECT * FROM portfolio ORDER BY id DESC");
if($query->num_rows > 0){
$i = 0;
while($row = $query->fetch_assoc()){
$imageURL = 'img/portfolio/'.$row["file_name"];
if ($i % 5 === 0) {
echo "<div class="clear"></div>";
}
$i++;
?>
<a href="<?php echo $imageURL; ?>">
<img src="<?php echo $imageURL; ?>" />
</a>
<?php } ?>
<?php } ?>
Вроде поправил, но все равно ругается!