【发布时间】:2018-03-22 13:40:00
【问题描述】:
我有一个当前不可点击的表格。单击行时,我想从该表转到详细信息页面,并在过程中传递 id 值。
我知道我需要在表格行上创建一个 href 并以某种方式在点击时传递 id 值,但不清楚如何执行此操作。相关表和php:
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="table-responsive m-t-40">
<table id="example23" class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<thead><tr><th title="Field #1">id</th>
<th title="Field #2">Organization</th>
<th title="Field #3">xxx</th>
<th title="Field #4">xxx</th>
<th title="Field #5">xxx</th>
<th title="Field #6">xxx</th>
</tr>
</thead>
<tbody>
<?php
$servername = "xxx";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}else{
echo '<script>console.log("Connection successful!")</script>';
}
$SELECT = mysqli_query($conn,"SELECT * FROM `organization`");
if($SELECT != false)
{
while($rows = mysqli_fetch_array($SELECT))
{
echo "
<tr>
<td>".$rows["id"]."</td>
<td>".$rows["name"]."</td>
<td>".$rows["xxx"]."</td>
<td>".$rows["xxx"]."</td>
<td>".$rows["xxx"]."</td>
<td>".$rows["xxx"]."</td>
</tr>
";
}
}else{
echo "
<tr>
<td colspan='3'>Something went wrong with the query</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
如何使我的表格行可点击(以转到详细信息页面)以及如何将点击时表格中的 id 值传递到详细信息页面?
【问题讨论】:
-
在下面查看我的答案:它将适用于整个