Bonjour,
Nouveau sur ce site et débutant en création de site je vous soumets un problème pour lequel je cherche une solution depuis deux jours.
J'affiche un tableau en php/mysql pour lequel j'ai fait une pagination, pour cela tout fonctionne.
Je voudrais afficher ce même tableau toujours paginé avec une requete sql, pourriez vous m'aider à construire cela.
Voici le code
<?php
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<?php
require 'fonctions.php';
//Connexion à la base de donn�es
include("../_connexion.php");
$link = mysql_connect ($host,$user,$pass) or exit(mysql_error());
$connexion = mysql_connect($host,$user,$pass) or die(mysql_error());
$db = mysql_select_db($db) or exit(mysql_error());
$bas=$_GET['limitbas'];
$haut=$_GET['limithaut'];
$limit=$_GET['limit'];
$select = "SELECT * FROM Compte23 LIMIT $bas, $limit";
$req = mysql_query($select, $connexion);
$result = mysql_query($select) or die ('Erreur : '.mysql_error() );
if (!$result){
echo mysql_error();
exit();
}
mysql_free_result ($result);
$total = mysql_num_rows($req);
?>
<!-- bootstrap -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="../bootstrap/css/bootstrap.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="../bootstrap/js/jquery.js" />
<link rel="stylesheet" href="../bootstrap/js/bootstrap.js" />
<link rel="stylesheet" href="../bootstrap/js/dataTables.bootstrap.js" />
<link rel="stylesheet" type="text/css" href="../Compte23/compte23.css" />
<!-- fin bootstrap -->
<script type="text/javascript" src="afficher_cacher_div.js"></script>
<script type="text/javascript" src="cacher_div.js"></script>
<script type="text/javascript" src="afficher_div.js"></script>
<script type="text/javascript" src="inlinemod.js"></script>
<script language="javascript">
function goLite(FRM,BTN)
{
window.document.forms[FRM].elements[BTN].style.backgroundColor = "#00CCFF";
}
function goDim(FRM,BTN)
{
window.document.forms[FRM].elements[BTN].style.backgroundColor = "#3399FF";
}
</script>
<SCRIPT language="javascript">
function popup(page) {
window.open(page);
}
function PopupCentrer(page,largeur,hauteur,options) {
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
</SCRIPT>
</head>
<body>
<div class="titre">
<div class="col-lg-12">
<INPUT TYPE=BUTTON VALUE="Accueil" style="width:17%" class="btn" ONCLICK="javascript:location.href = '../Index.php'" onMouseOver="goLite(this.form.name,this.name)" onMouseOut="goDim(this.form.name,this.name)">
<input type="BUTTON" Value="Export excel" class="btn" ONCLICK="javascript:location.href = 'ExportCompte23.php'" style="width:17%"/>
<INPUT TYPE=BUTTON VALUE="Solde () dont +1 an () --> <>% " style="width:34%" class="btn" ONCLICK="javascript:afficher_cacher('totaux');" onMouseOver="goLite(this.form.name,this.name)" onMouseOut="goDim(this.form.name,this.name)">
<INPUT TYPE=BUTTON VALUE="Cliquer ici pour ouvrir le formulaire de recherche." style="width:28%" class="btn" ONCLICK="javascript:location.href = 'compte23.php?razfiltre=0'; afficher('entete');" onMouseOver="goLite(this.form.name,this.name)" onMouseOut="goDim(this.form.name,this.name)">
</div></div>
<div id="entete">
<form id="monForm" action="compte23.php?razfiltre=1" method="post">
<div class="container">
<div class="row"></br>
<div class="col-lg-4">
<p>
<label for="RRelance">Relance : </label>
<input type="text" id="RRelance" name="RRelance" />
</p>
<p>
<label for="Rfiec">FIEC : </label>
<input type="text" id="Rfiec" name="Rfiec" />
</p>
<p>
<label for="Rstatut">Statut : </label>
<input type="text" id="Rstatut" name="Rstatut" />
</p>
<p>
<label for="Rsite">Site : </label>
<select id="Rsite" name="Rsite">
<option value="%">Toutes</option>
<option value="Brignoles">Brignoles</option>
<option value="Cannes">Cannes</option>
<option value="La Valette">La Valette</option>
<option value="Nice">Nice</option>
<option value="St Rapha�l">St Rapha�l</option>
<option value="Toulon">Toulon</option>
</select>
</p>
</div>
<div class="col-lg-4">
<p>
<label for="RPjt">Affaire : </label>
<input type="text" id="RPjt" name="RPjt" />
</p>
<p>
<label for="Rlibpjt">Libell� affaire : </label>
<input type="text" id="Rlibpjt" name="Rlibpjt" />
</p>
<p>
<label for="Rposiep">Position IEP : </label>
<select id="Rposiep" name="Rposiep">
<option value="%">Tous</option>
<option value="vide">Sans position IEP</option>
<option value="%affectation">En cours d'affectation</option>
<option value="%ex�cution">En �tude d'ex�cution</option>
<option value="%r�alisation">En r�alisation</option>
<option value="%exploitant">Ouvrage remis � l'exploitant</option>
<option value="Archiv�e">Archiv�e</option>
</select>
</p>
</div>
<div class="col-lg-4">
<p>
<label for="REOTP">EOTP : </label>
<input type="text" id="REOTP" name="REOTP" />
</p>
<p>
<label for="Rca">Charg� d'affaires : </label>
<input type="text" id="Rca" name="Rca" />
</p>
<p>
<label for="Rgrp" style="width:40%;">Agence : </label>
<select id="Rgrp" style="width:55%;" name="Rgrp">
<option value="%">Tous</option>
<option value="Raccordement">Raccordement</option>
<option value="D�lib�r�">D�lib�r�</option>
</select>
</p>
</div>
<div class="row">
<div class="col-lg-offset-3 col-lg-6">
<p>
</br>
<input type="submit" name="submit" class="btn" style="width:22%" ONCLICK="javascript:cacher('entete');"/>
<input type="reset" name="del" class="btn" style="width:22%" ONCLICK="javascript:location.href = 'compte23.php?razfiltre=0'";/>
<INPUT TYPE="BUTTON" VALUE="Fermer" name="masquer" class="btn" style="width:22%" ONCLICK="javascript:cacher('entete');"/>
</p>
</div>
</div>
</div></div></div>
<script type="text/javascript">
afficher_cacher('entete');
</script>
<div class="container">
<div id="content" class="row">
<table id="content" class="tableau" width="100%" cellspacing="0" >
<?php
include("../_connexion.php");
$limit = $_GET['limit'];
$page = $_GET['page'];
$limitbas = $_GET['limitbas'];
$limithaut = $_GET['limithaut'];
mysql_connect($host,$user,$pass);
mysql_select_db($db);
$total = mysql_query("SELECT COUNT(id) FROM compte23");
while($messages_total = mysql_fetch_array($total))
{
$resultatMessageTotal = $messages_total['COUNT(id)'];
$nombreDePages = ceil($resultatMessageTotal/$limit);
$pageAcctuel = $page;
$premierPage = 1;
$dernierPage = $nombreDePages;
$pageSuivante = $pageAcctuel+1;
$pagePrecedente = $pageAcctuel-1;
$premierMessage = ($pageAcctuel-1)*$resultatMessageTotal;
$dernierMessage = ($pageAcctuel+1)*$resultatMessageTotal;
}
if ($page == 1)
{
$pagePrecedente = 1;
}
if ($page == $dernierPage)
{
$pageSuivante = $dernierPage;
}
$result1=$pageSuivante*$limit-$limit;
$result2=$pageSuivante*$limit+$limit;
$pp1=$pagePrecedente*$limit-$limit;
$pp2=$dernierPage*$limit-$limit;
if ($total == 0) {
echo '</br></br></br>';
echo '<div id="info">';
echo '<p class="forme_texte">Aucune réponse trouvée.</p>';
echo '</div>';
}
else {
?>
<thead>
<tr>
<th>Id</th>
<th>Rlc</th>
<th>Fiec</th>
<th>Statut</th>
<th>Solde 23</th>
<th>Avant Date Pivot</th>
<th>Après Date Pivot</th>
<th>Max De MM-AAAA</th>
<th>Affaire</th>
<th>Libellé aff</th>
<th>EOTP</th>
<th>Libellé Eotp</th>
<th>Pos Eotp</th>
<th>ETI</th>
<th>NNI</th>
<th>CA</th>
<th>Groupe</th>
<th>Site</th>
<th>MeexRea</th>
<th>Traite</th>
<th>Att Decision</th>
<th>Commentaire</th>
<th>Position IEP</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="23">
<div id="pages">
<p style='text-align: left'>page <?php echo $pageAcctuel ?> / <?php echo $nombreDePages ?></p>
</div>
<div id="info">© Bruno Mathieu 2014</div>
<div id="page_navigation">
<ul class="pagination">
<li><a href="compte23.php?page=1 & limitbas=0 & limithaut=0 & limit=<?php echo $limit; ?>"><<</a></li>
<li><a href="compte23.php?page=<?php echo $pagePrecedente; ?> & limitbas=<?php echo $pp1; ?> & limithaut=0 & limit=<?php echo $limit; ?>"><</a></li>
<li><a href="compte23.php?page=<?php echo $pageSuivante; ?> & limitbas=<?php echo $result1; ?> & limithaut=0 & limit=<?php echo $limit; ?>">></a></li>
<li><a href="compte23.php?page=<?php echo $dernierPage; ?> & limitbas=<?php echo $pp2; ?> & limithaut=0 & limit=<?php echo $limit; ?>">>></a></li>
</ul>
</div>
</td>
</tr>
</tfoot>
<?php
while($user = mysql_fetch_array($req))
{
?>
<tbody>
<tr>
<td ><?php echo $user['id']; ?></td>
<td ><?php echo $user['Relance']; ?></td>
<td ><?php echo $user['Fiec']; ?></td>
<td ><?php echo $user['Statut']; ?></td>
<td ><?php echo $user['Solde23']; ?></td>
<td ><?php echo $user['DepAvantDatPivot']; ?></td>
<td ><?php echo $user['DepApresDatPivot']; ?></td>
<td ><?php echo $user['MaxDeMM-AAAA']; ?></td>
<td ><?php echo $user['Pjt']; ?></td>
<td ><?php echo $user['Libaffaire']; ?></td>
<td ><?php echo $user['EOTP']; ?></td>
<td ><?php echo $user['LibEotp']; ?></td>
<td ><?php echo $user['PosEotp']; ?></td>
<td ><?php echo $user['ETI']; ?></td>
<td ><?php echo $user['NNI']; ?></td>
<td ><?php echo $user['CA']; ?></td>
<td ><?php echo $user['Groupe']; ?></td>
<td ><?php echo $user['Site']; ?></td>
<td ><?php echo $user['MeexRea']; ?></td>
<td ><?php echo $user['Traite']; ?></td>
<td ><?php echo $user['AttDecision']; ?></td>
<td ><?php echo $user['Commentaire']; ?></td>
<td ><?php echo $user['PositionIEP']; ?></td>
</tr>
</tbody>
</div>
</div> <!-- fin div container -->
<?php
}}
mysql_free_result ($req);
?>
</table></br>
</body>
</html>
?>
ma requete créée dans un autre script php serait ceci par exemple
WHERE Compte23.Groupe LIKE 'Raccordement'
Je vous remercie pour votre aide