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
| <?php
session_start();
include_once('cnx.php');
$date = date("d-m-Y");
$heure = date("H:i");
include_once('head.php');
?>
<div id="menu2">
</div>
<div id="page">
<h1>Liste des Mareyeurs</h1>
<?php
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 =25;
// Connect to the server.
set_time_limit(0);
include_once('cnx.php');
if (!$conn)
die( print_r( sqlsrv_errors(), true));
set_time_limit(0);
$sql = "select * from V_Carte_Mar where Extrait is NULL";
$stmt = sqlsrv_query($conn, $sql, array(), array( "Scrollable" => 'static' ));
$num = sqlsrv_num_rows($stmt);
if ( !$stmt )
die( print_r( sqlsrv_errors(), true));
// Get the total number of rows returned by the query.
// Display links to "pages" of rows.
$rowsReturned = sqlsrv_num_rows($stmt);
if($rowsReturned === false){
die( print_r( sqlsrv_errors(), true));
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> ");
}
echo "<br/><br/>";
}
// Display the selected page of data.
echo "<table class='table2' border='1px'>
<tr>
<th>Racine</th>
<th>Nom</th>
<th width='1900'>Prenom</th>
<th>Type_Ref</th>
<th width='5000'>Raison_Sociale</th>
<th>Num_CIN</th>
<th>Série_Carte</th>
<th>Consulter Representant</th>
</tr>";
$pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
$page = getPage($stmt, $pageNum, $rowsPerPage);
foreach($page as $row)
echo "<tr>
<td>$row[1]</td>
<td>$row[9]</td>
<td width='1900'>$row[10]</td>
<td>$row[2]</td>
<td width='5000'>$row[3]</td>
<td>$row[8]</td>
<td>$row[11]</td>
<td><a href=\"Afficher_Representant.php?id=$row[1]\" target=\"_blank\">Consulter</a></td>
</tr>";
//<td>if ($row[2]=='m'){ "echo 'Société' "} else { "echo 'Personne Physique' "}</td>
echo "</table>";
echo "<br/>";
if($pageNum > 1)
{
$prevPageLink = "?pageNum=".($pageNum - 1);
echo "<a href='$prevPageLink'>Previous Page</a>";
}
// Display Next Page link if applicable.
if($pageNum < $numOfPages)
{
$nextPageLink = "?pageNum=".($pageNum + 1);
echo " <a href='$nextPageLink'>Next Page</a>";
}
// Display Previous Page link if applicable.
//<td><a href=\"getuser.php?q=$row[1]\">Consulrer Representant</a></td>
sqlsrv_close( $conn );
?>
</div>
</div>
</body>
</html> |
Partager