Rocco The Taco
Rocco The Taco

Reputation: 3797

Display MySQL JOIN in PHP results

I have added a recordset that successfully performs a JOIN on an existing results page:

mysql_select_db($database_redcross, $redcross);
$query_idToClient = "SELECT clientLName, clientFName FROM sys_client LEFT JOIN sys_visits USING (clientID)";
$idToClient = mysql_query($query_idToClient, $redcross) or die(mysql_error());
$row_idToClient = mysql_fetch_assoc($idToClient);
$totalRows_idToClient = mysql_num_rows($idToClient);

The result page also queries another table called sys_visits and displays results like this currently:

<table class="WADAResultsTable" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <th class="WADAResultsTableHeader">clientID:</th>
    <th>&nbsp;</th>
  </tr>
  <?php do { ?>
    <tr class="<?php echo $WARRT_AltClass1->getClass(true); ?>">

      <td class="WADAResultsTableCell">

      <a href="sys_visits_Detail.php?pid=<?php echo(rawurlencode($row_WADAsys_visits['pid'])); ?>" ><?php echo($row_WADAsys_visits['clientID']); ?></a></td>
    </tr>
  <?php } while ($row_WADAsys_visits = mysql_fetch_assoc($WADAsys_visits)); ?>
</table>

How do I echo the matching clientFName and clientLname from the recordset instead of just the id. The clientID is the same same in both tables.

Upvotes: 1

Views: 184

Answers (1)

Dorka
Dorka

Reputation: 196

while ($row = mysql_fetch_row($idToClient)) 
{
   echo "clientLName: " .$row[0] . "clientFName: " .$row[1];
}

Upvotes: 1

Related Questions