pb avec limitaiton d'affichage

Eléphanteau du PHP | 25 Messages

24 févr. 2007, 16:44

Bonjour,

Je suis en train de bloquer sur une limitation d'affiche.
Il s'agit d'une fiche produit. A gauche j'affiche le produit et à droite les autres poduits de la même marque. Je veux que la liste à droite soit limité à deux affichages, qu'il n'affiche pas de vignette si c'est le même produit que à gauche et que si pour une même marque il y a plus de 3 produits, il m'affiche un lien vers la liste complète.

J'ai fait ce code avec tous ces paramêtres mais du coup comme il me compte deux d'affichage max, il me compte dans les deux celui qui ne doit pas apparaître donc je me retrouve plus qu'avez 1 affichage :

http://www.rumbero-design.com/levy/fr/f ... te=Encinas

Voici le code :
<?


$query3 = "SELECT * FROM catalogue WHERE nom_artiste='$nomget' AND statut_catalogue='online'";
$result3 = mysql_query($query3)
or die (mysql_error());
 

  $nbResults = mysql_num_rows($result3); 

if($nbResults == 1){}

elseif($nbResults > 3){


echo"<table width='100%' border='0' align='center'><tr><td align='center'><br><br></td></tr>";

    $i = 0; 
  
  while (($ligne3 = mysql_fetch_array($result3)) !== false) { 
extract($ligne3);
    
    if($id_catalogue == $idget){}
	
  elseif($type_catalogue == "peinture"){

echo"<tr><td>
		<table width='192' border='0' cellpadding='0' cellspacing='0' class='bg_vignette' align='center'>
  <tr><td align='center' valign='bottom'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'>
<img src='../img_s/$image_s' border='0' width='178' height='134'>
</a></td>
  </tr>
  <tr>
    <td height='42'><table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0' class='bg_languette'>
        <tr>
          <td align='center' valign='top'><table width='156' border='0' cellspacing='0' cellpadding='0'>
              <tr>
                <td align='center' valign='middle' class='td_languette_lien'></td>
              </tr>
              <tr>
                <td align='center' valign='top' class='td_languette_peinture'></td>
              </tr>
          </table></td>
        </tr>
    </table></td></tr>
</table></td></tr>
";}

  elseif($type_catalogue == "sculpture"){
 
echo"<tr><td>
		<table width='192' border='0' cellpadding='0' cellspacing='0' class='bg_vignette' align='center'>
  <tr><td align='center' valign='bottom'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='../img_s/$image_s' border='0' width='178' height='134'></a></td>
  </tr>
  <tr>
    <td height='42'><table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0' class='bg_languette'>
        <tr>
          <td align='center' valign='top'><table width='156' border='0' cellspacing='0' cellpadding='0'>
              <tr>
                <td align='center' valign='middle' class='td_languette_lien'></td>
              </tr>
              <tr>
                <td align='center' valign='top' class='td_languette_sculpture'></td>
              </tr>
          </table></td>
        </tr>
    </table></td></tr>
</table></td></tr>

";}
	
	  else{
 
echo"<tr><td>
		<table width='192' border='0' cellpadding='0' cellspacing='0' class='bg_vignette' align='center'>
  <tr><td align='center' valign='bottom'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='../img_s/$image_s' border='0' width='178' height='134'></a></td>
  </tr>
  <tr>
    <td height='42'><table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0' class='bg_languette'>
        <tr>
          <td align='center' valign='top'><table width='156' border='0' cellspacing='0' cellpadding='0'>
              <tr>
                <td align='center' valign='middle' class='td_languette_lien'></td>
              </tr>
              <tr>
                <td align='center' valign='top' class='td_languette_mobilier'></td>
              </tr>
          </table></td>
        </tr>
    </table></td></tr>
</table></td></tr>

";}

    $i ++; 
    if ($i % 2 == 0 && $i != $nbResults) { 
     break; 
    }

}

echo"<tr><td valign='bottom' align='right'><a href='browse_fiche.php?prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='img/bt_voir_oeuvres.jpg' border='0'></a></td></tr></table>";}




else{

echo"<table width='100%' border='0' align='center'><tr><td align='center'><br><br></td></tr>";

    $i = 0; 

  while (($ligne3 = mysql_fetch_array($result3)) !== false) { 
extract($ligne3);
    
 if($id_catalogue == $idget){}
	
  elseif($type_catalogue == "peinture"){

echo"<tr><td>
		<table width='192' border='0' cellpadding='0' cellspacing='0' class='bg_vignette' align='center'>
  <tr><td align='center' valign='bottom'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='../img_s/$image_s' border='0' width='178' height='134'></a></td>
  </tr>
  <tr>
    <td height='42'><table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0' class='bg_languette'>
        <tr>
          <td align='center' valign='top'><table width='156' border='0' cellspacing='0' cellpadding='0'>
              <tr>
                <td align='center' valign='middle' class='td_languette_lien'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='img/bt_en_savoir_plus.jpg' border='0'></a></td>
              </tr>
              <tr>
                <td align='center' valign='top' class='td_languette_peinture'></td>
              </tr>
          </table></td>
        </tr>
    </table></td></tr>
</table></td></tr>
";}

  elseif($type_catalogue == "sculpture"){
 
echo"<tr><td>
		<table width='192' border='0' cellpadding='0' cellspacing='0' class='bg_vignette' align='center'>
  <tr><td align='center' valign='bottom'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='../img_s/$image_s' border='0' width='178' height='134'></a></td>
  </tr>
  <tr>
    <td height='42'><table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0' class='bg_languette'>
        <tr>
          <td align='center' valign='top'><table width='156' border='0' cellspacing='0' cellpadding='0'>
              <tr>
                <td align='center' valign='middle' class='td_languette_lien'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='img/bt_en_savoir_plus.jpg' border='0'></a></td>
              </tr>
              <tr>
                <td align='center' valign='top' class='td_languette_sculpture'></td>
              </tr>
          </table></td>
        </tr>
    </table></td></tr>
</table></td></tr>

";}
	
	  else{
 
echo"<tr><td>
		<table width='192' border='0' cellpadding='0' cellspacing='0' class='bg_vignette' align='center'>
  <tr><td align='center' valign='bottom'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste'><img src='../img_s/$image_s' border='0' width='178' height='134'></a></td>
  </tr>
  <tr>
    <td height='42'><table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0' class='bg_languette'>
        <tr>
          <td align='center' valign='top'><table width='156' border='0' cellspacing='0' cellpadding='0'>
              <tr>
                <td align='center' valign='middle' class='td_languette_lien'><a href='fiche.php?id_catalogue=$id_catalogue&prenom_artiste=$prenom_artiste&nom_artiste=$nom_artiste	'><img src='img/bt_en_savoir_plus.jpg' border='0'></a></td>
              </tr>
              <tr>
                <td align='center' valign='top' class='td_languette_mobilier'></td>
              </tr>
          </table></td>
        </tr>
    </table></td></tr>
</table></td></tr>

";}

    $i ++; 
    if ($i % 2 == 0 && $i != $nbResults) { 
     break; 
    }

}

echo"</table>";}
	?>
Merci pour votre aide !

Eléphanteau du PHP | 25 Messages

01 mars 2007, 17:50

personne ? :cry:

VaN
Mammouth du PHP | 1107 Messages

01 mars 2007, 18:31

Je ne comprends pas bien le problème, mais pourquoi ne mets tu pas une condition dasn la requete qui affiche la liste des produits annexes ?

du genre

Code : Tout sélectionner

WHERE article_id != '".$id_main_article."'"
où article_id est l'indentifiant unique dans ta table (je ne connais pas son nom), et $id_main_article, l'identifiant du produit que tu souhaite exclure de la liste, car il est affiché en gros a coté.

Eléphanteau du PHP | 25 Messages

01 mars 2007, 18:34

:shock:

pas pensé. la honte... Merci !

ViPHP
ViPHP | 4674 Messages

01 mars 2007, 19:41

Bonsoir :)

Penses à mettre Résolu si ton problème est bel et bien résolu ;-)
« Un handicap est le résultat d'une rencontre entre une déficience ou différence et une incapacité de la société à répondre à celle-ci. »

Hoa : http://hoa-project.net (sur @hoaproject).