Page 1 sur 1

Interrogation d'une BDD qui bug

Posté : 22 avr. 2007, 00:21
par sylvaing26
Encore moi,
lorsque j'interroge ma BDD pour

Code : Tout sélectionner

if ($id == 1 && $srb ==1)
tout fonction, ensuite si

Code : Tout sélectionner

if ($id == 1 && $srb ==2)
il m'affiche bien les images mais pas le nombre de pages

voici mon code complet :

Code : Tout sélectionner

<?php $id == $_GET['id']; $srb == $_GET['srb']; include ("inc/connect.php"); if ($id == 1 && $srb ==1){ @MYSQL_CONNECT($serveur,$utilisateur,$mdp) or die ("Connexion impossible"); @MYSQL_SELECT_DB($db) or die ("Connexion à la base $base impossible"); function CouperMot($result,$cut) { $message=wordwrap($result,$cut, " ", 1); return $result; } if ($id == 1 && $srb == 1){ $sql = mysql_query("SELECT nom, dossier, titre FROM animaux WHERE dossier='/domestiques/' "); $nbmsg=mysql_num_rows($sql); if($nbmsg=="") { echo "<center><b><p style margin-top:20;>Il n'y a pas de photos pour le moment</b></center></p>"; } } //// Initialisation affichage page par page //// if(empty($page)) $page=1; if(empty($total)) { $sql=mysql_query("SELECT nom, dossier, titre FROM animaux WHERE dossier='/domestiques/'"); $total=mysql_num_rows($sql); } $nb = '8'; //// On determine debut du limit //// $debut=($page-1)*$nb; $sql=mysql_query("SELECT nom, dossier, titre FROM animaux WHERE dossier='/domestiques/' ORDER BY id DESC LIMIT $debut,$nb"); while($result=mysql_fetch_array($sql)) { $result['nom']=CouperMot($result['nom'],$cut); $result['dossier']=CouperMot($result['dossier'],$cut); $titre="$result[titre]"; /////////////////////////// echo "<a href='voir.php?img=animaux"; //////////////////////////////////////// echo $result['dossier']; echo $result['nom']; echo "'>"; echo "<img src='animaux"; echo $result['dossier']; echo "vignettes/" ; echo $result['nom']; echo "' align='absmiddle' border='0' vspace='5' hspace='5' alt='$result[titre]'>"; echo "</a>"; } mysql_close(); //// Calcul du nombre de pages //// if($nbmsg > 0) { echo "<p style='margin-top:5; margin-right:30; margin-bottom:0; margin-left:30; padding:1px; border-top-width:1px; border-bottom-width:1px; border-bottom-color:rgb(87,113,39); border-top-style:dotted; border-bottom-style:dotted; border-tp-color:rgb(87,113,39);' align='right'>"; echo "<span style='font-size:8pt;'><font face='Verdana'>"; echo "Page :\n "; $nbpages = ceil($total / $nb); echo "</font>"; for($i = 1;$i <= $nbpages;$i ++) { echo "<a href=\"rubrique.php?id=1&rub=animaux&full=yes&page=$i&total=$total\"><span style='font-size:8pt;'><font face='Verdana'>$i</a> \n"; if($i < $nbpages) {echo " - "; } }} echo "</p>"; echo "</font>"; echo "</span>"; echo "<p style='margin-top:5; margin-right:30; margin-bottom:0; margin-left:30; padding:1px; border-top-width:1px; border-bottom-width:1px; border-bottom-color:rgb(87,113,39); border-top-style:dotted; border-bottom-style:dotted; border-tp-color:rgb(87,113,39);' align='right'>"; ////////////////////////////// echo "<a href='rubrique.php?id=1&rub=animaux'><span style='font-size:8pt;'><font face='Verdana'>"; //////////////////////////// echo "Retour"; echo "</font>"; echo "</span>"; echo "</a></p>"; } //////////////////////////////// //// ///////////////////////// elseif ($id == 1 && $srb == 2){ @MYSQL_CONNECT($serveur,$utilisateur,$mdp) or die ("Connexion impossible"); @MYSQL_SELECT_DB($db) or die ("Connexion à la base $base impossible"); function CouperMot($result,$cut) { $message=wordwrap($result,$cut, " ", 1); return $result; } if ($id == 1 && $srb == 1){ $sql = mysql_query("SELECT nom, dossier, titre FROM animaux WHERE dossier='/ferme/'"); $nbmsg=mysql_num_rows($sql); if($nbmsg=="") { echo "<center><b><p style margin-top:20;>Il n'y a pas de photos pour le moment</b></center></p>"; } } //// Initialisation affichage page par page //// if(empty($page)) $page=1; if(empty($total)) { $sql=mysql_query("SELECT nom, dossier, titre FROM animaux WHERE dossier='/ferme/'"); $total=mysql_num_rows($sql); } $nb = '8'; //// On determine debut du limit //// $debut=($page-1)*$nb; $sql=mysql_query("SELECT nom, dossier, titre FROM animaux WHERE dossier='/ferme/' ORDER BY id DESC LIMIT $debut,$nb"); while($result=mysql_fetch_array($sql)) { $result['nom']=CouperMot($result['nom'],$cut); $result['dossier']=CouperMot($result['dossier'],$cut); $titre="$result[titre]"; /////////////////////////// echo "<a href='voir.php?img=animaux"; //////////////////////////////////////// echo $result['dossier']; echo $result['nom']; echo "'>"; echo "<img src='animaux"; echo $result['dossier']; echo "vignettes/" ; echo $result['nom']; echo "' align='absmiddle' border='0' vspace='5' hspace='5' alt='$result[titre]'>"; echo "</a>"; } mysql_close(); //// Calcul du nombre de pages //// if($nbmsg > 0) { echo "<p style='margin-top:5; margin-right:30; margin-bottom:0; margin-left:30; padding:1px; border-top-width:1px; border-bottom-width:1px; border-bottom-color:rgb(87,113,39); border-top-style:dotted; border-bottom-style:dotted; border-tp-color:rgb(87,113,39);' align='right'>"; echo "<span style='font-size:8pt;'><font face='Verdana'>"; echo "Page :\n "; $nbpages = ceil($total / $nb); echo "</font>"; for($i = 1;$i <= $nbpages;$i ++) { echo "<a href=\"rubrique.php?id=1&rub=animaux&full=yes&page=$i&total=$total\"><span style='font-size:8pt;'><font face='Verdana'>$i</a> \n"; if($i < $nbpages) {echo " - "; } }} echo "</p>"; echo "</font>"; echo "</span>"; echo "<p style='margin-top:5; margin-right:30; margin-bottom:0; margin-left:30; padding:1px; border-top-width:1px; border-bottom-width:1px; border-bottom-color:rgb(87,113,39); border-top-style:dotted; border-bottom-style:dotted; border-tp-color:rgb(87,113,39);' align='right'>"; ////////////////////////////// echo "<a href='rubrique.php?id=1&rub=animaux'><span style='font-size:8pt;'><font face='Verdana'>"; //////////////////////////// echo "Retour"; echo "</font>"; echo "</span>"; echo "</a></p>"; } ?> <p>&nbsp;</p>

Posté : 22 avr. 2007, 00:30
par charabia
Je n'ai pas tout lu mais déjà le début n'est pas bon.
$id == $_GET['id']; 
$srb == $_GET['srb'];
Tu ne dois pas mettre un double égal qui est utilisé pour les comparaison mais un simple pour les déclarations à ce niveau.

NB : utilises la balise php au lieu de code pour colorer ta syntaxe, c'est beaucoup plus compréhensible.

Posté : 22 avr. 2007, 15:09
par sylvaing26
ok merci
Je ne savais pas la difference entre la signification du = et du ==.
Pour mon code je le fait autrement
Je met donc ce sujet en Delestage