Requete sql

BapPro Messages postés 46 Date d'inscription   Statut Membre Dernière intervention   -  
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   -
Bonjour,

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


$req=mysqli_query($dbc, "SELECT ContactName FROM  claims_follow_up.Office p inner join claims_follow_up.user o On p.ClientID=o.office Where o.username='".$u."' and o.password='".$p."' ");
        while($tab=mysqli_fetch_array($req))
        {
        $clname=$tab['ContactName'];
                 }
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 ContactName FROM  claims_follow_up.Office p inner join claims_follow_up.user o On p.ClientID=o.office Where o.username='".$u."' and o.password='".$p."' "); <br>        while($tab=mysqli_fetch_array($req)) <br>       {<br>       $clname=$tab['ContactName'];<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

1 réponse

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

Visiblement tu sais faire une jointure... 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 ContactName
         FROM Office P
        INNER JOIN user U ON U.office = P.ClientID
        WHERE U.username = '$u'
           AND  U.password = '$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