Requete sql

BapPro Messages postés 46 Date d'inscription   Statut Membre Dernière intervention   -  
jordane45 Messages postés 38472 Date d'inscription   Statut Modérateur Dernière intervention   - 30 nov. 2015 à 22:14
Bonjour,

J'ai cette requete qui m'affiche deux valeurs
pierre
jean

$req=mysqli_query($dbc, "SELECT Name FROM  claims_follow_up.Office p inner  claims_follow_up. o On p.ClientID=o.office Where o.name='".$u."' and o.='".$p."' ");
        while($tab=mysqli_fetch_array($req))
        {
        $clname=$tab['Name'];
                 }
echo $clname;

Dans une autre table avec un champ contenant ces deux valeurs je voudrais afficher tous les donnees contenant ces deux valeurs. J'ai essaye mais le resultat m'affiche les donnees seulement pour pierre, jean est omis
$req=mysqli_query($dbc, "SELECT Name FROM  claims_follow_up.Office p inner  claims_follow_up. o On p.ClientID=o.office Where o.name='".$u."' and o.='".$p."' "); <br>        while($tab=mysqli_fetch_array($req)) <br>       {<br>       $clname=$tab['Name'];<br>  $req7=mysqli_query($dbc, "select * from claims_follow_up.Claims_assigned where office_manager='".$clname."' "); <br><table><tr>
<th>Edit</th>
<th>Claim Status</th>
<th>Office</th>
<th>Insurance Carrier</th>
<th>Phone#</th>
<th>DOS</th>
<th>Billed Amount</th>
</tr>
<?php while($final_result =mysqli_fetch_array($req7))
   {
?>
 <tr>
   
  <td><?php echo $final_result['Claim_Status'] ;?> </td>
 <td><?php echo $final_result['office'];?> </td>
 <td><?php echo $final_result['insurance_carrier'];?></td>
 <td><?php echo $final_result['Phone_num'];?> </td>
 <td><?php echo $final_result['DOS'] ?></td>
<td><?php echo $final_result['BilledAmount'] ;?></td>
 </tr>
<?php
   }
   }
  ?>


De l'aide s'il vous plait
A voir également:

1 réponse

jordane45 Messages postés 38472 Date d'inscription   Statut Modérateur Dernière intervention   4 744
 
Bonjour,

Visiblement tu sais faire une ture... ne te manque plus qu'à savoir utiliser une sous-requête.

Essayes ceci :
//préparation de LA requête
$sql= "SELECT * 
       FROM  Claims_assigned CA
       WHERE CA.office_manager IN (
          SELECT Name
         FROM Office P
        INNER   U ON U.office = P.ClientID
        WHERE U.name = '$u'
           AND  U. = '$p' 
      )";

//exécution de la reqûete    
$req = $req=mysqli_query($dbc,$sql) or die(mysqli_error($dbc));

?>
<br>
<table>
<tr>
 <th>Edit</th>
 <th>Claim Status</th>
 <th>Office</th>
 <th>Insurance Carrier</th>
 <th>Phone#</th>
 <th>DOS</th>
 <th>Billed Amount</th>
</tr>

<?php while($row =mysqli_fetch_array($req)) { ?>
 <tr>
  <td><?php echo $row['Claim_Status'] ;?> </td>
  <td><?php echo $row['office'];?> </td>
  <td><?php echo $row['insurance_carrier'];?></td>
  <td><?php echo $row['Phone_num'];?> </td>
  <td><?php echo $row['DOS'] ?></td>
 <td><?php echo $row['BilledAmount'] ;?></td>
 </tr>
<?php
} //Fin du while
?>


Cordialement, 
Jordane                                                                 
0