bonjour,
j’ai rencontre un problème d’erreur en créons ma pagination
! ) Notice: Undefined variable: reqProducts in C:\wamp64\www\boutique\article1.php on line 28
Fatal error: Uncaught Error: Call to a member function fetch() on null in C:\wamp64\www\boutique\article1.php on line 28
( ! ) Error: Call to a member function fetch() on null in C:\wamp64\www\boutique\article1.php on line 28
page1 nom= article1.php
<?php
session_start();
include('basedonne.php');
include('pagination.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<title>IMPACT BOUTIQUE</title>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css" >
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap-responsive.min.css" >
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="corps.css">
</head>
<body class="body">
<?php
include 'menu.php';
?>
<?php
include 'section.php';
?>
<section class="fakeimg">
<div class="content">
<div class="topcontent">
<div id="products_box">
<?php
while($products = $reqProducts->fetch()){
?>
<div id='single_product'>
<h6 class="post-info"><?php echo($resultat['DESIGNATION']) ?></h6>
<img src="<?php echo($resultat['PHOTO']) ?>" width="170" height="170"><br>
<p class="post_info"><b><?php echo($resultat['PRIX']) ?> FCFA</b></p>
<a href="detail.php?IDPRODUIT=$IDPRODUIT" style="float: left">Details</a>
<a href="index.php?add_cart=$IDPRODUIT"><button style="float: right">Add to cart</button></a>
</div>
<?php
}
?>
</div>
</div>
</div>
<ul class="pagination">
<li class="<?php if($current == '1'){ echo "disabled"; } ?>"><a href="?p=<?php if($current != '1'){ echo $current-1; }else{ echo $current; } ?>">«</a></li>
<?php
for($i=1; $i<=$nbPage; $i++){
if($i == $current){
?>
<li class="active"><a href="?p=<?php echo $i ?>"><?php echo $i ?></a></li>
<?php
}else{
?>
<li><a href="?p=<?php echo $i ?>"><?php echo $i ?></a></li>
<?php
}
}
?>
<li class="<?php if($current == $nbPage){ echo "disabled"; } ?>"><a href="?p=<?php if($current != $nbPage){echo $current+1;}else{ echo $current;} ?>">»</a></li>
</ul>
</section>
<?php
include_once 'footer.php';
?>
</body>
</html>
page2 mon pagination.php
<?php
include('basedonne.php');
$perPage = 5;
$req = $bdd->query('SELECT COUNT(*) AS total FROM produits');
$result = $req->fetch();
$total = $result['total'];
$nbPage = ceil($total/$perPage);
if(isset($_GET['p']) && !empty($_GET['p']) && ctype_digit($_GET['p']==1)){
if($_GET['p'] > $nbPage){
$current = $nbPage;
}else{
$current = $_GET['p'];
}
}else{
$current = 1;
}
$firstOfPage = ($current-1)*$perPage;
$repProducts = $bdd->query("SELECT * FROM produits ORDER BY IDPRODUIT ASC LIMIT $firstOfPage,$perPage");
?>
+0
-0