Je sollicite l'aide de personne plus avancées que moi pour m' apporter un solution .
je n' arrive pas à paginer les resultats de ma recherche multicritère.
La pagination que j' ai adapté marche lorsqu' il sagit d'afficher toutes les info , mais ne marche pas losque j'aplique la requete sql en rouge
voici ci dessous le code de la page .
http://www.africonnexion.com/default.php?page=repertoire_tri
<?php require_once('Connections/req.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_repert = 10;
$pageNum_repert = 0;
if (isset($_GET['pageNum_repert'])) {
$pageNum_repert = $_GET['pageNum_repert'];
}
$startRow_repert = $pageNum_repert * $maxRows_repert;
mysql_select_db($database_req, $req);
$query_repert = "SELECT * FROM afriwork09 WHERE secteur='$_REQUEST[secteur]' AND pays='$_REQUEST[pays]' AND ville LIKE '%$_POST[ville]%' ORDER BY secteur ASC";
$query_limit_repert = sprintf("%s LIMIT %d, %d", $query_repert, $startRow_repert, $maxRows_repert);
$repert = mysql_query($query_limit_repert, $req) or die(mysql_error());
$row_repert = mysql_fetch_assoc($repert);
if (isset($_GET['totalRows_repert'])) {
$totalRows_repert = $_GET['totalRows_repert'];
} else {
$all_repert = mysql_query($query_repert);
$totalRows_repert = mysql_num_rows($all_repert);
}
$totalPages_repert = ceil($totalRows_repert/$maxRows_repert)-1;
mysql_select_db($database_req, $req);
$query_sect = "SELECT DISTINCT secteur FROM afriwork09 ORDER BY secteur ASC";
$sect = mysql_query($query_sect, $req) or die(mysql_error());
$row_sect = mysql_fetch_assoc($sect);
$totalRows_sect = mysql_num_rows($sect);
mysql_select_db($database_req, $req);
$query_pays = "SELECT DISTINCT pays FROM afriwork09 ORDER BY pays ASC";
$pays = mysql_query($query_pays, $req) or die(mysql_error());
$row_pays = mysql_fetch_assoc($pays);
$totalRows_pays = mysql_num_rows($pays);
mysql_select_db($database_req, $req);
$query_ville = "SELECT DISTINCT ville FROM afriwork09 ORDER BY ville ASC";
$ville = mysql_query($query_ville, $req) or die(mysql_error());
$row_ville = mysql_fetch_assoc($ville);
$totalRows_ville = mysql_num_rows($ville);
mysql_select_db($database_req, $req);
$query_commune = "SELECT DISTINCT commune FROM afriwork09 ORDER BY commune ASC";
$commune = mysql_query($query_commune, $req) or die(mysql_error());
$row_commune = mysql_fetch_assoc($commune);
$totalRows_commune = mysql_num_rows($commune);
$queryString_repert = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_repert") == false &&
stristr($param, "totalRows_repert") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_repert = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_repert = sprintf("&totalRows_repert=%d%s", $totalRows_repert, $queryString_repert);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<style type="text/css">
<!--
.Style12 {color: #000000}
.Style2 { font-size: 10px;
color: #FF0000;
}
.pibrepert {
background-color: #FFF;
background-image: url(arrierepubrep.jpg);
background-position: left top;
}
-->
</style>
</head>
<body>
<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="arrier repert1.jpg" width="790" height="150" /></td>
</tr>
<tr>
<td height="65"><form id="form1" name="form1" method="post" action="default.php?page=repertoire_tri">
<table width="722" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="102"> </td>
<td width="122">secteur</td>
<td width="4"> </td>
<td width="4"> </td>
<td width="149">pays</td>
<td width="10"> </td>
<td width="9"> </td>
<td width="144" style="color: #F00">Saisir la ville sans faute</td>
<td width="184"> </td>
</tr>
<tr>
<td> </td>
<td><label for="secteur"></label>
<select name="secteur" id="secteur">
<?php
do {
?>
<option value="<?php echo $row_sect['secteur']?>"<?php if (!(strcmp($row_sect['secteur'], ucfirst($row_sect['secteur'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_sect['secteur']?></option>
<?php
} while ($row_sect = mysql_fetch_assoc($sect));
$rows = mysql_num_rows($sect);
if($rows > 0) {
mysql_data_seek($sect, 0);
$row_sect = mysql_fetch_assoc($sect);
}
?>
</select></td>
<td> </td>
<td> </td>
<td><label for="pays"></label>
<select name="pays" id="pays">
<?php
do {
?>
<option value="<?php echo $row_pays['pays']?>"<?php if (!(strcmp($row_pays['pays'], $row_pays['pays']))) {echo "selected=\"selected\"";} ?>><?php echo $row_pays['pays']?></option>
<?php
} while ($row_pays = mysql_fetch_assoc($pays));
$rows = mysql_num_rows($pays);
if($rows > 0) {
mysql_data_seek($pays, 0);
$row_pays = mysql_fetch_assoc($pays);
}
?>
</select></td>
<td> </td>
<td> </td>
<td><label for="ville"></label>
<input type="text" name="ville" id="ville" /></td>
<td><input type="submit" name="Recheche" id="Recheche" value="Rechercher" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form></td>
</tr>
</table>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="769" height="238" align="center" valign="top" scope="col"><table width="579" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="579" height="219" scope="col"><br />
<?php do { ?>
<table width="459" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="459" height="166" style="background-repeat: no-repeat; background-image: url(arrier%20repert2.jpg);"><table width="580" border="0" align="center" cellpadding="0" cellspacing="0">
<!-- fwtable fwsrc="Sans titre" fwbase="repert.jpg" fwstyle="Dreamweaver" fwdocid = "1764264203" fwnested="0" -->
<tr>
<td width="527"><img src="images/spacer.gif" width="513" height="1" border="0" alt="" /></td>
<td width="33"><img src="images/spacer.gif" width="16" height="1" border="0" alt="" /></td>
<td width="20"><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<td height="153" valign="bottom"><table width="499" height="149" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#86D1F1">
<tr>
<td width="26%" height="149" align="center" valign="middle"><?php
$img = $row_repert['image'];
if ($img == "") // le prenom est vide
echo '<img src="images/default.jpg">';
else // le prenom est pas vide
echo '<img src="upload/'.$img .'" width="112" height="100" >';
?></td>
<td width="2%" align="center" valign="top"> </td>
<td width="72%" align="left" valign="middle" class="Style12"><span style="color: #CC6601"><?php echo $row_repert['entreprise']; ?></span><br />
<?php echo $row_repert['secteur']; ?><br />
<?php echo $row_repert['pays']; ?><br />
<?php echo $row_repert['ville']; ?> <?php echo $row_repert['commune']; ?><br />
<span style="color: #CD6600"><?php echo $row_repert['telephone']; ?></span><br />
<table width="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="default.php?page=voir_pme_pmi&ID=<? echo $row_repert['ID']; ?>.html"><img src="images/ensavoir.jpg" alt="" width="108" height="25" border="0" /></a></td>
</tr>
</table></td>
</tr>
</table>
<p style="margin:0px"></p></td>
<td> </td>
<td><img src="images/spacer.gif" width="1" height="119" border="0" alt="" /></td>
</tr>
</table></td>
</tr>
</table>
<?php } while ($row_repert = mysql_fetch_assoc($repert)); ?>
<br style="background-repeat: no-repeat;" /></th>
</tr>
</table>
Parcourez les pages:
<?php // ICI LE CODE A INSERER en l'adaptant au nom de votre jeu d'enregsitrement !
$last=$totalPages_repert+1;
$current=$pageNum_repert+1;
for ($i = 1; $i <= $last; $i++) {
if($current==$i){
echo "<strong> ". $i . "</strong> | ";
} else { ?>
<a href="<?php printf("%s?pageNum_repert=%d%s", $currentPage, min($totalPages_repert, $i+1), $queryString_repert); ?>"><?php echo $i;?></a><?php echo " | "; ?>
<?php
}
}
?></th>
<th width="10" align="left" valign="top" scope="col"> </th>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($repert);
mysql_free_result($sect);
mysql_free_result($pays);
mysql_free_result($ville);
mysql_free_result($commune);
?>
javascript:void(0);