在Dreamweaver php中显示来自两个mysql表的数据

时间:2016-02-13 06:40:03

标签: php mysql dreamweaver

这是我的两个带代码和输出的mysql表

casestatic table display records output

案例日期表就像这样。:

 CREATE TABLE `casedt` (
  `SlNo` bigint(7) NOT NULL,
  `AdvUser` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  `FileNo` int(5) NOT NULL,
  `NextDt` date NOT NULL,
  `Comments` varchar(100) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

 mysql_select_db($database_MyDatabase, $MyDatabase);
$query_casedate = sprintf("SELECT * FROM casedt WHERE AdvUser = %s", GetSQLValueString($colname_casedate, "text"));
$casedate = mysql_query($query_casedate, $MyDatabase) or die(mysql_error());
$row_casedate = mysql_fetch_assoc($casedate);
$totalRows_casedate = mysql_num_rows($casedate);
<p>Cause List for Advocate: <?php echo $row_AdvUser['FullName']; ?> for Date: <?php echo $row_casedate['NextDt']; ?></p>
      <table width="600" border="1">
        <tr>
          <td>File No.</td>
          <td>Case Title</td>
          <td>Client Side</td>
          <td>Court Name</td>
          <td>Case Type</td>
         </tr>
        <tr>
          <td>          <?php echo $row_casedate['FileNo']; ?></td>
          <td>            <?php echo $row_CaseStatic['CaseTitle']; ?></td>
          <td>            <?php echo $row_CaseStatic['ClientSide']; ?></td>
          <td>            <?php echo $row_CaseStatic['CourtName']; ?></td>
          <td>  <?php echo $row_CaseStatic['CaseType']; ?></td>
          </tr>
      </table>

显示的记录仅适用于特定日期。我想显示该特定日期和特定顾问的所有记录。这些代码是在Dreamweaver cs6中为php文件生成的。请指导和帮助

1 个答案:

答案 0 :(得分:0)

请在此处查看此声明,

$row_casedate = mysql_fetch_assoc($casedate);

您只从结果集中获取一行。删除此行并循环遍历<table>内的整个结果集,如下所示:

// your code    

<table width="600" border="1">
<tr>
  <td>File No.</td>
  <td>Case Title</td>
  <td>Client Side</td>
  <td>Court Name</td>
  <td>Case Type</td>
</tr>
<?php
    while($row_casedate = mysql_fetch_assoc($casedate)){
        ?>
        <tr>
            <td><?php echo $row_casedate['FileNo']; ?></td>
            <td><?php echo $row_CaseStatic['CaseTitle']; ?></td>
            <td><?php echo $row_CaseStatic['ClientSide']; ?></td>
            <td><?php echo $row_CaseStatic['CourtName']; ?></td>
            <td><?php echo $row_CaseStatic['CaseType']; ?></td>
        </tr>
        <?php
    }
?>
</table>

旁注:不使用mysql_*函数,从PHP 5.5开始不推荐使用它们,在PHP 7.0中完全删除它们。请改用mysqlipdoAnd this is why you shouldn't use mysql_* functions