*Variable *not defined but its defined in the getAllproducts not sure why its saying that when its declared
public function getAllProducts(){
$limit = 12;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$start = ($page - 1) * $limit;
$this->db->query("SELECT tbl_products. * , tbl_users.username, tbl_users.avatar, categories.name FROM tbl_products
INNER JOIN tbl_users
ON tbl_products.users_id = tbl_users.user_id
INNER JOIN categories
ON tbl_products.categories_id = categories.cat_id
ORDER BY created_date DESC
limit $start,$limit");
$results = $this->db->resultSet();
return $results;
$this->db->query('SELECT count(pro_id) AS pro_id FROM tbl_products');
$row = $this->db->resultSet();
$total = $row[0]['pro_id'];
$pages = ceil($total / $limit);
return $this->db->rowCount();
}
There other code is here
<?php if($products) : ?>
<div class="container">
<?php foreach( $products as $product ) : ?>
<div class="card">
<img src="img/products/<?php echo $product->image; ?>" alt="">
<div class="title"><a href="product.php?pro_id=<?php echo $product->pro_id; ?>"><?php echo $product->title; ?></a></div>
<div class="desc"><?php echo trimtext($product->descs ,0,85); ?></div>
</div>
<?php endforeach; ?>
<?php for ($i=1; $i < $pages; $i++) : ?>
<a href="products.php?pages=<?php $i; ?>"><?php $i; ?> </a>
<?php endfor ; ?>
</div>
<?php else : ?>
<div class="error"><p>No Products Posted Yet</p></div>
<?php endif; ?>
I really appreciate your help in advance
i Searched on google i couldn't find the desired result i tried passing the data in the function nothing not sure why am new
i want the pages to be generated dynamically from the database enter image description here