Bonjour à tous et toutes,

Dans un script PHP je fais la requête MYSQL suivante pour afficher différentes fiches de prestataires:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
 
 
<?php
$ProfRecherche = $_SESSION[Rec]['Detail'];    // Liste des corps de métiers recherché
$NbProfRecherche = count($ProfRecherche);   // Nombre de corps de métiers recherché
 
$reqtxt = "SELECT clients_rubriques.Client_Id, clients_rubriques.Region, clients_rubriques.Rubrique_Id, clients_rubriques.Sous_Rubriques_Id, clients_rubriques.Business FROM clients_rubriques WHERE clients_rubriques.Region LIKE '%".$_SESSION[Rec]['Region']."%' AND (clients_rubriques.Sous_Rubriques_Id LIKE '%".$ProfRecherche[0]."%'";
 
if($NbProfRecherche > 1) {
  for($i=1; $i < $NbProfRecherche; $i++) {
   $reqtxt.= " OR clients_rubriques.Sous_Rubriques_Id LIKE '%".$ProfRecherche[$i]."%'";
  }
 
$reqtxt.=") ORDER BY clients_rubriques.Business DESC, RAND() ";
$reqsql = mysql_query($reqtxt) OR DIE("ERREUR: ".$reqtxt);
 
$Nbr	= mysql_num_rows($reqsql);
?>
<h2 class="postheader"><span class="postheadericon">Les <?=$Nbr;?> résultats correspondant à votre recherche... </span></h2>
 </div>
 <div class="postcontent">
   <div class="content-layout layout-item-0">
    <div class="content-layout-row">
      <div class="layout-cell layout-item-1" style="width: 100%;">
        <table class="article" border="0" cellspacing="0" cellpadding="0" style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; width: 100%;">
        <tbody>
          <tr>
          <td style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: top;"><span style="text-align: justify;">&nbsp;</span><br /></td>
         </tr>
         <tr>
        <td></td>
         </tr>
       </table>
     <div class="content-layout" style="width: 100%;">
     <div class="content-layout-row" style="width: 100%;">
      <div class="layout-cell layout-item-old-0" style="width: 100%;"> </div>
     </div>
     </div>
     </div>
     </div>
     </div>
       </div>
       </div>
       <div>
<?php
$fd = "#FFF5CE";
while($row	= mysql_fetch_assoc($reqsql))
{
$reqTxtFourn= "SELECT Id,Societe,Ville,Departement,Descriptif,Logo,Business,Vues FROM clients WHERE Id = '".$row['Client_Id']."' limit 1";
											$reqSqlFourn = mysql_query($reqTxtFourn) OR DIE("ERREUR: ".$reqTxtFourn);
while($Fournisseur = mysql_fetch_assoc($reqSqlFourn)) {
												$Fou_Id          =	$Fournisseur['Id'];
$Fou_Societe  =	$Fournisseur['Societe'];
$Fou_Ville  = $Fournisseur['Ville'];
$Fou_Departement = $Fournisseur['Departement'];
$Fou_Descriptif = html_entity_decode($Fournisseur['Descriptif'],ENT_QUOTES,"UTF-8");
$Fou_Logo = $Fournisseur['Logo'];
$Fou_Business = $Fournisseur['Business'];
$Fou_Vues = $Fournisseur['Vues'] + 1;
$q1 = mysql_query("SELECT * FROM compt_vues where cpt_adresse_ip = '".$_SERVER["REMOTE_ADDR"]."' ");						if(mysql_num_rows($q1) == 0) {
$maj	= mysql_query("UPDATE clients SET Vues = '".$Fou_Vues."' WHERE Id = '".$row['Client_Id']."' limit 1");
$SupIp = time()-2592000;      // Suppression après 30 jours de l'adresse IP du visiteur.
$sup	= mysql_query("DELETE FROM compt_vues WHERE cpt_date > '".$SupIp."' ");											$q2 = mysql_query("INSERT INTO compt_vues (cpt_id,cpt_adresse_ip,cpt_date) VALUES ('NULL','".$_SERVER["REMOTE_ADDR"]."', '".time()."' )" );
 
$ProfFournisseur = explode('|',unserialize($row['Sous_Rubriques_Id']));
$CptFournisseur = count($ProfFournisseur);
$Profession = "";
											if($NbProfRecherche > 0) 
for($j=0; $j < $CptFournisseur; $j++)
{
   if (in_array ($ProfRecherche[$j], $ProfFournisseur,true))
     {	
         $reqMettxt	= "SELECT srub_nom FROM sous_rubriques WHERE srub_active = 1 AND (srub_id = '".$ProfRecherche[$j]."') LIMIT 1";
$reqMetsql	= mysql_query($reqMettxt) OR DIE("ERREUR: ".$reqMettxt);
$Profession.= mysql_result($reqMetsql,0,"srub_nom").", ";
      }
     }																					
    }
 
$CptMetier = count($Metier);	
if($Fou_Business == 1) {$ClassBusiness = "TableRecherche"; $AffichePro = "Professionnel";} else { $ClassBusiness = "TableRechercheNonBusiness"; $AffichePro = "";
}
if($Nbr <= $NbrListAff) { ?>
 
<!-- DEBUT DE TABLE DE LISTE -------------------------------- -->
<table class='TableRecherche<?php if($Fou_Business == 0){ echo "NonBusiness";} ?>' border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%" align="center" valign="middle"><img id="Photo" src="../users/logos/Ico_<?=$Fou_Logo;?>" width="70" height="70" alt=""></td>
<td width="83%">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="18%" valign="top"><div align="left"><strong><?=$Fou_Societe;?></strong></div></td>
<td width="29%" valign="top"><?=$Profession;?></td>
<td width="17%" valign="top"><strong><?=$Fou_Ville;?></strong></td>
<td width="22%" valign="top"><strong><?=$Fou_Departement;?></strong></td></tr>
<tr>
<td colspan="4" valign="top"><?=$Fou_Descriptif;?></td>
 </tr>
<tr>
<td><a href="details.php" class="art-button">Plus de détails</a></td>
<td><a href="details.php" class="art-button">Envoyer une demande de devis</a></td>
<td>&nbsp;</td>
<td><?php if($Fou_Business == 1){ echo "<img src='../images/profess.png' width='79' height='14'>";}?></td>
</tr>
</table>
</td>
</tr>
</table>
<hr width="850px">
<!-- FIN DE TABLE DE LISTE -------------------------------- -->
<?php
}
else
{
  if($Lig == 0)
  {
  ?>
   <table width="95%" border="1" bordercolor="#FFF0B7" cellspacing="0" cellpadding="2">
    <tr class="TdEnteteCenterWhite">
     <td>Dépt.</td>
        <td>Ville</td>
           <td width="12%">Enseigne</td>
		<td>Descriptif</td>
			<td>Vues</td>
<td>Pro</td>
</tr>
<?php 
$Lig = 1;
}
if($fd == "#FFFEF0") { $fd = "#FFF5CE";}
elseif($fd == "#FFF5CE") { $fd = "#FFFEF0";}?>
<tr bgcolor="<?=$fd;?>" onmouseover="this.bgColor='#FFCC33';" onmouseout="this.bgColor='<?=$fd;?>';" title="Cliquez pour voir la fiche complète..."; onclick="document.location.href='details.php?ID=<?=$Fou_Id;?>';" style="cursor:pointer;">
<td><?=$Fou_Departement;?></td>
<td><?=ucwords(strtolower($Fou_Ville));?></td>
<td><?=$Fou_Societe;?></td>
<td><?php
if(strlen($Fou_Descriptif) > 75)
{
$Fou_Descriptif = substr($Fou_Descriptif,0,70)."... <span class='ASuivre'><em>à suivre</em></span>";
}
echo $Fou_Descriptif;?></td>
<td style="width:80px;" align="right"><?=$Fou_Vues;?> fois&nbsp;</td>
<td style="width:80px;"><?php if($Fou_Business == 1){ echo "<img src='../images/profess.png' width='79' height='14'>";}?></td>
</tr>
<?php 
$Lig++;
if(($Lig-1) == $Nbr) { ?></table><?php }
}		// FIN DE LA CONDITION 2
}		// FIN DE LA BOUCLE PRINCIPALE
?>
La recherche se fait, mais ne s'affiche pas comme je le désirerai.
C'est à dire:

1- afficher en premier les fiches avec la valeur Business = 1 mais avec tri aléatoire
2- afficher ensuite les fiches avec la valeur Business = 0 mais avec tri aléatoire.

Auriez-vous une idée ?

Merci de vos réponses et bonne journée.