gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 20:07:37 24 4
gpt4 key购买 nike

我是 PHP 新手,所以请耐心等待。我正在工作中从事一个数据库项目,并在那里实习。我正在尝试显示一个表格,因为数据已从数据库中获取。我有3张 table

表 vege_plant

  • uuid
  • 姓名

表 vege_location

  • uuid
  • 地点

表 vege_data

  • uuid
  • vege_plants_uuid
  • vege_location_uuid
  • 横断面编号
  • 象限编号
  • 还活着
  • 死了

我的 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>';
}

但是,它无法显示,也没有警告任何错误。我不知道我哪里错了。

最佳答案

尝试一下,第一行有一个语法错误,缺少单个 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))

关于php - 显示来自 3 个 SQL 表的表数据并使用 php 条件显示 - 使用完全连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40290157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com