Page 1 sur 1

positionnement des reponses par mysql_fetch_array

Posté : 01 janv. 2008, 20:04
par chris51200
Comment puis je positionner les tableaux qui vont sortir de mes reponses avec cette fonction?
voici mon code


if($_POST['prixmini'] == "40000" and $_POST['prixmaxi'] == "80000") // prix compris entre 40 000 et 80 000€	 
	  
	  {
	     
		 
		   $reponse = mysql_query("SELECT id, type, prix, descriptif, lien, fond FROM bdd WHERE prix >= 40000 AND prix <= 80000 ORDER BY prix"); // Requête SQL
           while ($donnees = mysql_fetch_array($reponse) )
           {
           ?>
        <tr> 
          <td colspan="2" style="position:absolute; left:230px; top:200px; z-index:2"><table width="700" height="300" border="2" cellpadding="0" cellspacing="0" <?php echo '<body background="image page/'.$donnees['fond'].'">'; ?>>
              <tr> 
                <td width="50" height="40">n&deg;</td>
                <td width="100" height="40">exclu/agence/vendu</td>
                <td width="50" height="40">coup coeur</td>
                <td width="50" height="40">r&eacute;f: <?php echo $donnees['id']; ?></td>
                <td width="300" height="40">d&eacute;signation:<?php echo $donnees['descriptif']; ?></td>
                <td width="150" height="40">Prix:<?php echo $donnees['prix']; ?>€</td>
              </tr>
              <tr> 
                <td colspan="4"><?php echo '<img src="image/'.$donnees['lien'].'">';?></td>
                <td colspan="2"><?php echo $donnees['descriptif']; ?></td>
              </tr>
              <tr> 
                <td height="30" colspan="4">En savoir plus</td>
                <td height="30" colspan="2">&nbsp;</td>
              </tr>
            </table>

Posté : 01 janv. 2008, 22:38
par Xenon_54
Qu'entends-tu par positionner? Tu parles de l'affichage à l'écran? Du tri des résultats?

Posté : 02 janv. 2008, 00:58
par chris51200
et bien ce tableau est imbriquer dans un autre tableau, je voudrais positionner la repetition dans une des cellules du deuxieme tableau

Posté : 02 janv. 2008, 01:14
par Xenon_54
Pourquoi imbriquer 2 tableaux?

Autrement, tu n'as qu'à déplacer le début et fin de ta boucle au bon endroit non?

Posté : 02 janv. 2008, 05:51
par Patriboom
Bah euh ...

il ne suffirait pas de clore ta cellule du tableau 1, puis le rang du tableau 1 après quoi on referme l'accolade puis le tableau 1

bref:
if($_POST['prixmini'] == "40000" and $_POST['prixmaxi'] == "80000") // prix compris entre 40 000 et 80 000€     
      
      {
         
         
           $reponse = mysql_query("SELECT id, type, prix, descriptif, lien, fond FROM bdd WHERE prix >= 40000 AND prix <= 80000 ORDER BY prix"); // Requête SQL
           while ($donnees = mysql_fetch_array($reponse) )
           {
           ?>
        <tr> 
          <td colspan="2" style="position:absolute; left:230px; top:200px; z-index:2">
					  <table width="700" height="300" border="2" cellpadding="0" cellspacing="0" <?php echo '<body background="image page/'.$donnees['fond'].'">'; ?>>
              <tr> 
                <td width="50" height="40">n&deg;</td>
                <td width="100" height="40">exclu/agence/vendu</td>
                <td width="50" height="40">coup coeur</td>
                <td width="50" height="40">r&eacute;f: <?php echo $donnees['id']; ?></td>
                <td width="300" height="40">d&eacute;signation:<?php echo $donnees['descriptif']; ?></td>
                <td width="150" height="40">Prix:<?php echo $donnees['prix']; ?>€</td>
              </tr>
              <tr> 
                <td colspan="4"><?php echo '<img src="image/'.$donnees['lien'].'">';?></td>
                <td colspan="2"><?php echo $donnees['descriptif']; ?></td>
              </tr>
              <tr> 
                <td height="30" colspan="4">En savoir plus</td>
                <td height="30" colspan="2">&nbsp;</td>
              </tr>
            </table>
         </td><td>Autres colonnes</td>
      </tr>
<?php  }     ?>
</table>


J'ignore (mais j'aimerais bien le savoir) ce qu'en pensent les spécialistes, mais si la manipulation du tableau 1 demande plus de souplesse, tu pourrais même envoyer toute tes définitions de tableaux2 dans un variable en Array. Ensuite, lorsque le moment opportun arrive, tu décharge un à un les tableaux 2.

Ou encore, tu planque dans ta définition de tableau 1 une référence à une fonction qui régit la construction d'un tableau2 spécifique du genre:
 function tableau2($varibales_necessaires) {

   tout ton bataclan ci-haut
}

Code : Tout sélectionner

<table blababla> <tr> <td>Première colonne</td> <td><?php tableau2("MonChoix"); ?> </td> <td>Troisième colonne</td> <tr> </table>


Et salut à mon compatriote Xenon (du Québec)!