Php 打印数据库表并根据其子行颜色为父行上色
PHP页面必须显示数据库表的内容。在另一个表中,我将使用该值相应地打印行并显示为子行Php 打印数据库表并根据其子行颜色为父行上色,php,jquery,html-table,Php,Jquery,Html Table,PHP页面必须显示数据库表的内容。在另一个表中,我将使用该值相应地打印行并显示为子行 $result = pg_query($conn, "SELECT *,'SENT' as direction FROM table1 WHERE identification LIKE '%$identification%' AND expedition LIKE '$expedition' order by date DESC LIMIT '$limit' "); 这将在一段时间内打印此类表格: whil
$result = pg_query($conn, "SELECT *,'SENT' as direction FROM table1 WHERE identification LIKE '%$identification%' AND expedition LIKE '$expedition' order by date DESC LIMIT '$limit' ");
这将在一段时间内打印此类表格:
while ($row = pg_fetch_row($result)) {
$sql2 = pg_query($conn, " SELECT quantity FROM expedition WHERE identification='$row[2]' ");
$row2 = pg_fetch_row($sql2);
$color="white";
if ($row2[0] == "-1") { $color="red";}
if ($row2[0] == "1") { $color="green";}
if ($row2[0] == "0") { $color="grey";}
echo "<tr bgcolor=\"$color\">
<td><button class=\"btn btn-info\" type=\"button\" data-toggle=\"collapse\" data-target=\"#$row[2]\">+</button></td>
<td>row[0]</td>
<td>row[1]</td>
<td>row[2]</td>
<td>row[3]</td>
<td>row[4]</td>
<td>...and more</td>
</tr>";
echo "<tr><td colspan=9><div style=\"background-color:$color\" id=\"$row[2]\" class=\"collapse\">$row2[0]</div></td></tr> ";
while($row=pg\u fetch\u row($result)){
$sql2=pg_query($conn,“从远征中选择数量,其中标识=“$row[2]”);
$row2=pg_fetch_行($sql2);
$color=“白色”;
如果($row2[0]==“-1”){$color=“red”}
如果($row2[0]=“1”){$color=“green”;}
如果($row2[0]=“0”){$color=“grey”;}
回声“
+
第[0]行
第[1]行
第[2]行
第[3]行
第[4]行
……还有更多
";
回显“$row2[0]”;
我正在使用引导添加一个按钮,单击该按钮后,将打开一个隐藏行,内容为$sql2
。我将直接在
之后打印查询
请注意,第一个查询为row[]
,第二个查询为row2[]
问题:如果第二个查询包含多个结果,并且在所有情况下标识都不是PK(因此可能会有更多),则我无法为每一行打印其子项的颜色