我正在尝试在另一个表行之间放置一个表(注释板位于跟踪板之间)。插入跟踪板表行之间的记事板表通过主键(issue_ID)相关联。我不能简单地加入和循环数据,因为跟踪板表的大部分信息都是非常重复的,我最终会使用JavaScript来选择“最小化”或隐藏记事板信息。我唯一的问题是为$ rdx_ID分配一个自适应变量,当我的函数循环遍历所有的追踪板行时,该变量会发生变化。
<html>
<body>
<?php
$con = mysqli_connect('localhost', 'root', '', 'disolDemo');
$sql = "SELECT * FROM trackingboard";
$result = mysqli_query($con, $sql) or die("Bad Query: $sql");
$sql2 = "SELECT * FROM notesboard";
$result2 = mysqli_query($con, $sql2) or die("Bad Query: $sql2");
$rdx_ID = '1';
while($row = mysqli_fetch_assoc($result)){
?>
<?php echo"
<table>
<tr>
<th>Action</th>
<th>Issue ID</th>
<th>Customer</th>
<th>Order Type</th>
<th>Origin</th>
<th>Destination</th>
</tr>
<tr>";?>
<td><a href="edit.php?idx=<?php echo $row['issue_ID'] ?>">edit</a>
</td>
<?php echo"
<td>{$row['issue_ID']}</td>
<td>{$row['customer']}</td>
<td>{$row['orderType']}</td>
<td>{$row['origin']}</td>
<td>{$row['destination']}</td>
</tr></table>
<table><tr>
<th>issue_ID</th>
<th>note_ID</th>
<th>noteDate</th>
<th>noteTime</th>
<th>note</th>
</tr>";
$query1 = $con->query("SELECT * FROM notesboard WHERE issue_ID =
'$rdx_ID'") or die($con->error);
while($row = $query1->fetch_assoc()){;
?>
<tr>
<?php echo"
<td>{$row['issue_ID']}</td>
<td>{$row['note_ID']}</td>
<td>{$row['noteDate']}</td>
<td>{$row['noteTime']}</td>
<td>{$row['note']}</td>
</tr>";
}
}
echo'<table>';
?>
</body>
</html>