probleme de pagination php

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : probleme de pagination php

par dunbar » 03 août 2008, 00:30

Rajoute une } a la fin de ton code

probleme de pagination php

par banban55 » 02 août 2008, 21:26

Bonsoir à tous,

Je vous explose mon problème, je souhaite mettre un place une pagination pour la navigation de mes enregistrements sql...

je vous présente le que code php en question, qui me pose problème en faite. j'ai une " Parse error " à la ligne 173....

avez vous une idée de la raison du problème ?


<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('institut');

/**
* DÉTERMINE LE NOMBRE DE LIGNE À AFFICHER
*/
$limit_par_page = 15;

if(isset($_GET['page']))
{
$page = $_GET['page'];
$page = $page - 1;
}
else
{
$page = 0;
}
$from = $page * $limit_par_page;


$sql = mysql_query("SELECT * FROM institut LIMIT $from,$limit_par_page" ) or die(mysql_error());

while($donnees = mysql_fetch_array($sql))
{


echo $donnees['categorie'].' / '.$donnees['titre'].' / '.$donnees['prix_h'].' / '.$donnees['prix_f'].' / '.$donnees['description'].'<p><p>';
}


$sql2 = mysql_query("SELECT COUNT(*) AS nb_msg FROM institut" );
$donnees2 = mysql_fetch_array($sql2);
$nb_msg = $donnees2['nb_msg'];
$nb_pages = ceil($nb_msg / $limit_par_page);

for($page=1;$page<=$nb_pages;$page++)
{
?><!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"><!-- InstanceBegin template="/Templates/admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>accueil</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
@import url("styleadmin.css");
-->
</style>
<!-- InstanceEndEditable -->
<link href="styleadmin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td height="140" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="900" height="140"><img src="images/template_01.jpg" width="900" height="140" alt="header" /></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td width="82" height="376" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="82" height="376"><img src="images/template_02.jpg" width="82" height="376" alt="gauche" /></td>
        </tr>
    </table></td>
    <td width="723" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr><!-- InstanceBeginEditable name="page" -->
        <td width="723" height="376" valign="top" bgcolor="#252525" class="h1"><table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td><div align="center" class="h2">Bienvenu dans votre pannel de gestion de vos tarifs </div></td>
            </tr>
            <tr>
              <td height="13"><div align="left"><a href="accueil.php" class="h1">Liste des tarifs</a> -<a href="aj_tarifs.php" class="h1"> Ajout d'un tarif</a> - <a href="aj_cate.php" class="h1">ajout d'une nouvelle cat&eacute;gorie</a> </div></td>
            </tr>
            <tr>
              <td height="13">&nbsp;</td>
            </tr>
          </table>          
          <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td height="324" valign="middle"><table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr class="ligne1tb">
                  <td width="161">Les cat&eacute;gories</td>
                  <td width="220">pr&eacute;stations</td>
                  <td width="63"><div align="center">tarifs H </div></td>
                  <td width="62"><div align="center">tarifs F </div></td>
                  <td width="39">&nbsp;</td>
                </tr>
                <tr onmouseover="this.className='tabover'" onmouseout="this.className='tabnormal'">
                  <td valign="middle" class="h2"><table>
                    </table>
                      <img src="images/puce.gif" alt="puce" width="5" height="5" />
                      <?php

$chaine = $donnees['categorie'];
$lg_max = 28; //nombre de caractère autoriser

if (strlen($chaine) > $lg_max)
{
$chaine = substr($chaine, 0, $lg_max);
$last_space = strrpos($chaine, " ");
$chaine = substr($chaine, 0, $last_space)." ...";
}

echo $chaine;

?></td>
                  <td class="h2"><?php

$chaine = $donnees['titre'];
$lg_max = 50; //nombre de caractère autoriser

if (strlen($chaine) > $lg_max)
{
$chaine = substr($chaine, 0, $lg_max);
$last_space = strrpos($chaine, " ");
$chaine = substr($chaine, 0, $last_space)." ...";
}

echo $chaine;

?></td>
                  <td class="h2"><div align="center"><?php echo $donnees['prix_h']; ?></div></td>
                  <td class="h2"><div align="center"><?php echo $donnees['prix_f']; ?></div></td>
                  <td class="tabover"><div align="right"><a href="sauvegarde.php?id=<?php echo $donnees['id']; ?>"><img src="images/stop.gif" alt="suppr" width="15" height="15" border="0" /></a><img src="images/parametres.gif" alt="modif" width="15" height="15" /></div></td>
                </tr>
              </table>
                <table width="650" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><a href="sauvegarde.php?page=<?php echo $page; ?>"><?php echo $page; ?></a></td>
                  </tr>
                </table></td>
            </tr>
          </table>          
          </td>
      <!-- InstanceEndEditable --></tr>
    </table></td>
    <td width="95" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="95" height="376"><img src="images/template_04.jpg" width="95" height="376" alt="droite" /></td>
      </tr>
    </table>    </td>
  </tr>
  <tr>
    <td height="62" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="900" height="62"><img src="images/template_05.jpg" width="900" height="62" alt="footer" /></td>
        </tr>
    </table></td>
  </tr>
</table>
</body>
<!-- InstanceEnd -->
</html>