1

我添加了一个在现有结果页面上成功执行 JOIN 的记录集:

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);

结果页面还查询另一个名为 sys_visits 的表,并显示当前结果如下:

<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>

如何从记录集中回显匹配的 clientFName 和 clientLname 而不仅仅是 id。两个表中的 clientID 相同。

4

1 回答 1

1
while ($row = mysql_fetch_row($idToClient)) 
{
   echo "clientLName: " .$row[0] . "clientFName: " .$row[1];
}
于 2012-10-11T11:30:50.723 回答