Précédent   Forum des professionnels en informatique > PHP > Langage
Langage Forum sur le langage PHP, la POO, les conventions, la sécurité, etc. Avant de poster : FAQ Langage, toutes les FAQ PHP, cours langage et sources PHP
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 02/05/2011, 10h07   #1
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
Par défaut probleme pagination en php

Bonjour a tous,

est ce que vous pouvez m'aidez svp j'ai un soucis quand j'ajoute le code de pagination ma page s'affiche une erreur et je ne sais ou d'ouvient voila mon code:

Code :
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
 
<!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">
<body><table align="center" bgcolor="#000000"><tr>
  <td>anim
    </td></tr>
<tr><td>menu</td></tr>
<tr><td height="27" bgcolor="#FFFFFF"><table width="219" border="0">
  <tr>
    <td width="94" height="21"><?php
  @session_start();
include("connection.php");
 $a=mysql_query("select * from projet ");
//$b=mysql_fetch_array($a);
//echo $b['id_projet'];
			$nombMaxPage=3;
			//$nombMaxPage = 10; //nombre par page
			$numPageCour =1; //n° de la fiche courante
 
			$Ndeb=@$_GET["num"]; //1ère fiche transmise par l'URL
?>
   Bonjour,<span class="session"><?php echo'',$_SESSION['login_user'],''; ?></span></td>    
    <td width="10"><b>|</b></td>
    <td width="101"><h5><a href="deconnexion.php"><strong>Deconnexion</strong></a></h5></td>
  </tr>
</table></td></tr>
<form method="post" action="form2.php">
 
  <table width="258" height="48" border="0" align="center">
 <tr>
    <td height="21" colspan="3" bgcolor="#000000"><div align="center"><strong>Liste des Projets pour CQExport</strong></div></td>
    </tr>
  <?php while (($b=mysql_fetch_array($a)) && ($numPageCour<$nombMaxPage+$Ndeb)){ 
 
 	if($numPageCour>=$Ndeb) 
				{
					 ?> 
       <tr> <td width="252" height="21" bgcolor="#000000"><a href="affich_config.php?id_projet=<?php echo($b['id_projet']); ?>"><?php echo($b['nom_projet']); ?></a></td>
       <td>&nbsp;</td>
        </tr>
         <?php $numPageCour++; } ?>
</table></form></tr></table>
<table align="center" cellpadding="3">
  <tr>
    <?php 
	// Navigation: Des fiches avant ?
	if($Ndeb > 0) { ?>
    <td valign="top"><a href="">Retour</a></td>
    <?php } ?>
    <td><?php // N° des pages
$Npag = ceil(mysql_numrows($a)/$nombMaxPage);
for($i=1;$i<=$Npag;$i++) {
   // Page courante ?
   if($Ndeb == ($i-1)*$nombMaxPage) { ?>
      Page <?php echo $i; ?>
      <?php } else { ?>
      <a href=""> <?php echo $i; ?></a>
      <?php }
} ?></td>
    <?php // Des fiches après ?
if($val) { ?>
    <td valign="top"><a href="aa.php">Suite</a></td>
    <?php } ?>
</tr></table></body></html>
voila erreur :
Code :
1
2
 
Parse error: parse error in D:\CQIET\wamp\www\projet_NDS\user.php on line 66
Merci D'avance.
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/05/2011, 10h43   #2
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
j'ai trouvé ou d'ouvient l'erreur c'est seulement que j'ai oublié de fermer } de while mais maintenat mon code m'affiche 2 projet par page quand je clique sur suite pour voir le reste des projet il m'affiche rien voila mon code apres la modification:
Code :
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
<!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">
<body><table align="center" bgcolor="#000000"><tr>
  <td><?php include('header_v.php');?>
    </td></tr>
<tr><td><?php include('menu_user.php');?></td></tr>
<tr><td height="27" bgcolor="#FFFFFF"><table width="219" border="0">
  <tr>
    <td width="94" height="21"><?php
  @session_start();
include("connection.php");
 
?>
   Bonjour,<span class="session"><?php echo'',$_SESSION['login_user'],'';?></span></td>    
    <td width="10"><b>|</b></td>
    <td width="101"><h5><a href="deconnexion.php"><strong>Deconnexion</strong></a></h5></td>
    <td><?php $a=mysql_query("select * from projet ");
//$b=mysql_fetch_array($a);
//echo $b['id_projet'];
			$nombMaxPage=3;
			//$nombMaxPage = 10; //nombre par page
			$numPageCour =1; //n° de la fiche courante
 
			$Ndeb=@$_GET["num"]; //1ère fiche transmise par l'URL</td>
 ?> </tr>
</table></td></tr>
<form method="post" action="#">
 
  <table width="258" height="48" border="0" align="center">
 <tr>
    <td height="21" colspan="3" ><div align="center"><strong>Liste des Projets pour CQExport</strong></div></td>
    </tr>
  <?php while (($b=mysql_fetch_array($a)) && ($numPageCour<$nombMaxPage+$Ndeb)){ 
 
 	if($numPageCour>=$Ndeb) 
				{
					 ?> 
       <tr> <td width="252" height="21" ><a href="affich_config.php?id_projet=<?php echo($b['id_projet']); ?>"><?php echo($b['nom_projet']); ?></a></td>
       <td>&nbsp;</td>
        </tr>
         <?php $numPageCour++;}}?>
</table></form></tr></table>
<table align="center" cellpadding="3">
  <tr>
    <?php 
	// Navigation: Des fiches avant ?
	if($Ndeb > 0) { ?>
    <td valign="top"><a href="user.php">Retour</a></td>
    <?php } ?>
    <td><?php // N° des pages
$Npag = ceil(mysql_numrows($a)/$nombMaxPage);
for($i=1;$i<=$Npag;$i++) {
   // Page courante ?
   if($Ndeb == ($i-1)*$nombMaxPage) { ?>
      Page <?php echo $i; ?>
      <?php } else { ?>
      <a href="user.php"> <?php echo $i; ?></a>
      <?php }
} ?></td>
    <?php // Des fiches après ?
if($b) { ?>
    <td valign="top"><a href="user.php">Suite</a></td>
    <?php } ?>
</tr></table></body></html>
Merci d'avance de m'aider
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/05/2011, 11h12   #3
Membre Expert
 
Avatar de transgohan
 
Homme Baptiste ROUSSEL
Étudiant
Inscription : janvier 2011
Messages : 802
Détails du profil
Informations personnelles :
Nom : Homme Baptiste ROUSSEL
Localisation : France, Territoire de Belfort (Franche Comté)

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : janvier 2011
Messages : 802
Points : 1 515
Points : 1 515
Premièrement :
Code php :
$Ndeb=@$_GET["num"];
est plus que moche...
Correction :
Code php :
$Ndeb = (!empty($_GET['num'])) ? intval($_GET['num']) : 0;
Même remarque pour le session_start()...
Le soucis que tu as avec vient du fait qu'il doit être la première instruction du script et surtout être avant tout affichage... Or tu affiches du HTML avant.

Ensuite le soucis vient de l'initialisation de tes variables. $numPageCour est toujours statique, donc tu ne pourras jamais afficher une autre page.

Et j'ai pas compris ton code de pagination... comment peux-tu changer de page et afficher la suite sans passer un seul paramètre ?
transgohan est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 02/05/2011, 11h30   #4
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
merci pour ta reponse en faite pour le code de pagination je l'ai trouvé sur le net et moi aussi j'ai pas b1 compris ce code mais j'ai pas le choix je ne sais pas comment je peux faire la pagination c'est pour ca j'ai copié ce code et maintenant je galére est que tu peux m'aider je ne sais pas comment je vais passer les parametres pour changer la page .

Merci d'avance.
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/05/2011, 11h38   #5
Membre Expert
 
Avatar de transgohan
 
Homme Baptiste ROUSSEL
Étudiant
Inscription : janvier 2011
Messages : 802
Détails du profil
Informations personnelles :
Nom : Homme Baptiste ROUSSEL
Localisation : France, Territoire de Belfort (Franche Comté)

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : janvier 2011
Messages : 802
Points : 1 515
Points : 1 515
Un peu de lecture : http://antoine-herault.developpez.co...atique-en-php/
transgohan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/05/2011, 14h34   #6
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
merci infiniment avec ce tuto je peux changer ma page et afficher la suite facilement
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 09h40.


 
 
 
 
Partenaires

Hébergement Web