Bonsoir
j'ai un problème concernant la pagination "il affiche que les 10 premiers lignes" après avoir cliquer sur d'autre numéro de page je reçois le message suivant
No rows returned
voila le code et merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
session_start();
include_once('cnx.php');
$date = date("d-m-Y");
$heure = date("H:i");
include_once('head.php');
?>
 
	<div id="menu2">
      <ul>
        <!-- Texte Menu droit de la page &agrave; modifier  -->
        <li><a href="espace_dpm.php" title=""> Page d'accueil </a></li>
        <li><a href="consulter_eta_dpm.php" title="">Consulter données</a></li>
		<li><a href="compte_dpm.php" title="">Modifier votre compte</a></li>
        <li><a href="authentification.php?deco=1" title="">Se déconnecter</a></li>
      </ul>
  </div>
  <div id="page">
	<h1>Resultat de recherche </h1>
 
<?php
// Connect to the server.
set_time_limit(0);
include_once('cnx.php');
if (!$conn)
	die( print_r( sqlsrv_errors(), true));
// Define and execute the query.  
// Note that the query is executed with a "scrollable" cursor.
$_SESSION['n']=$_POST["n"]; 
	 $_SESSION['m']=$_POST["m"]; 
	 $_SESSION['cm']=$_POST["cm"]; 
	 $_SESSION['cd']=$_POST["cd"]; 
	 $_SESSION['c']=$_POST["c"]; 
	 $_SESSION['d']=$_POST["d"]; 
     $_SESSION['e']=$_POST["Designation_Entite"]; 
$n=$_SESSION['n']; 
	 $m= $_SESSION['m']; 
	 $cm=$_SESSION['cm']; 
	 $cd=$_SESSION['cd']; 
	 $c=$_SESSION['c']; 
	 $d= $_SESSION['d']; 
     $e= $_SESSION['e']; 
 
 
 $sql = "Select  * from V_ETA where Date_Vente  Between '".$c."' and '".$d."' ";
 
	if($m!=''){
 
				$sql = $sql. " and Nom_Acheteur like '".$m."' ";
				}
	if($cm!=''){
				$sql = $sql. " and Code_Acheteur='".$cm."' ";
				}
	if($n!=''){
				$sql =$sql.  " and Vendeur like '%".$n."%'  ";
				}
	if($cd!=''){
				$sql =$sql.  " and Code_Vendeur='".$cd."' ";
 
			}
	if($e!=-1){
				$sql = $sql.  " and libelle='".$e."' ";	
				}
 
				$sql = $sql.  " order by Nom_Acheteur ,Code_Acheteur,Vendeur,Code_Vendeur,Date_Vente,libelle";	
		echo $sql;
$ress=$sql;
 
$stmt = sqlsrv_query($conn, $ress, array(), array( "Scrollable" => 'static' ));
if ( !$stmt )
	die( print_r( sqlsrv_errors(), true));
 
// Get the total number of rows returned by the query.
// Display links to "pages" of rows.
 
function getPage($stmt, $pageNum, $rowsPerPage)
{
	$offset = ($pageNum - 1) * $rowsPerPage;
	$rows = array();
	$i = 0;
	while(($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC, SQLSRV_SCROLL_ABSOLUTE, $offset + $i)) && $i < $rowsPerPage)
	{
		array_push($rows, $row);
		$i++;
	}
	return $rows;
}
// Set the number of rows to be returned on a page.
$rowsPerPage = 10;
$rowsReturned = sqlsrv_num_rows($stmt);
if($rowsReturned === false)
    die( print_r( sqlsrv_errors(), true));
elseif($rowsReturned == 0)
{
    echo "No rows returned.";
	exit();
}
else
{     
    // Display page links.
    $numOfPages = ceil($rowsReturned/$rowsPerPage);
    for($i = 1; $i<=$numOfPages; $i++)
    {
        $pageLink = "?pageNum=$i";
        print("<a href=$pageLink>$i</a>&nbsp;&nbsp;");
    }
    echo "<br/><br/>";
}
 
// Display the selected page of data.
echo "<table border='1px'>";
echo "<tr><td>Code Entité</td><td>Désignation Entité</td><td>Code Mareyeur</td><td>Nom Marayeur</td><td>Poids Acheté</td><td>Poids Vendu</td></tr>";
$pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
$page = getPage($stmt, $pageNum, $rowsPerPage);
 
foreach($page as $row)
	echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[6]</td><td>$row[7]</td></tr>";
 
echo "</table>";
 
sqlsrv_close( $conn );
?>
 
</div>
<div id="footer"> Copyright ©  <a href="index.php">GESTION DE TRACABILITE DES PRODUITS DE LA MER </a> | Designed by|  <a href="www.onp.co.ma/">ONP</a> </div>
</div>
</body>
</html>