显示来自3个sql表的表数据并使用php条件显示 - 使用完全连接

时间:2016-10-27 16:47:37

标签: php mysql sql

我是PHP的新手,所以请耐心等待。我正在研究工作中的数据库项目,我在那里实习。 考虑到已从数据库中提取数据,我试图显示一个表。我有3张桌子

表vege_plant

  • uuid
  • 名称

表vege_location

  • UUID
  • 位置

表vege_data

  • uuid
  • vege_plants_uuid
  • vege_location_uuid
  • transect_num
  • quadrant_num
  • alive

我的PHP代码如下所示:

<?php

       $sql = mysql_query('SELECT vege_data.*, vege_location.*, vege_plants.*
       FROM vege_data
       JOIN vege_location ON vege_location.uuid =vege_data.vege_location_uuid
       JOIN vege_plants ON vege_plants.uuid = vege_data.vege_plants_uuid;);
            echo '<table class = "table table-hover">
<thead>
    <tr>
        <th>Location</th>
        <th>Transect Number</th>
        <th>Quadrat Number</th>
        <th>Plant Name</th>
        <th>Alive</th>
        <th>Dead</th>
        <th>Action</th>
    </tr>
</thead>
<tbody>';
            $count = 1;    

while ($row = mysql_fetch_assoc($result)) {
            echo '<tr>';
            echo '<td contenteditable="true">';
            echo '<td>';
            echo $row['location'];
            echo '</td>';
            echo '</td>';
            echo '<td contenteditable="true">';
            echo $row['transect_num'];
            echo '</td>';
            echo '<td contenteditable="true">';
            echo $row['quadrant_num'];
            echo '</td>';
            echo '<td contenteditable="true">';
            echo $row['name'];
            echo '</td>';
            echo '<td contenteditable="true">';
            echo $row['alive'];
            echo '</td>';
            echo '<td>';
            echo $row['dead'];
            echo '</td>';
            echo '</tr>';
        }

但是,它无法显示,也没有提示任何错误。我不知道自己哪里出错了。

1 个答案:

答案 0 :(得分:0)

尝试这在第1行qoute缺失

时出现语法错误
   $sql = mysql_query('SELECT vege_data.*, vege_location.*, vege_plants.*
   FROM vege_data
   JOIN vege_location ON vege_location.uuid =vege_data.vege_location_uuid
   JOIN vege_plants ON vege_plants.uuid = vege_data.vege_plants_uuid;');


while ($row = mysql_fetch_array($result))