因此,我在网站上有一个历史记录,我想从单击的行中获取值,并仅针对该行ID显示它们。我有表,但是当我单击每一行时,它为
等不同行显示了相同的值HTML代码:
std::valarray
这是js代码:
<table style="width:100%" id="listagem">
<thead>
<tr>
<th style="font-family: Arial; font-size: 20px;">Data</th>
<th style="font-family: Arial; font-size: 20px;">Sala</th>
<th style="font-family: Arial; font-size: 20px;">Tipo</th>
</tr>
</thead>
<tbody>
<?php
$result = mysqli_query($conn, "SELECT * FROM `ocorrencia` as o ORDER BY
o.data DESC");
while($row = mysqli_fetch_assoc($result)): ?>
<tr id="tr" onclick="hide(), window.location = '#bg'">
<td idlista="<?php echo $row['id']; ?>" style="display:visible;font-family:
Arial; font-size: 12px;"><a><?php echo $row['id']; ?></a></td>
<td style="font-family: Arial; font-size: 17px;"><?php echo $row['data']; ?>
</td>
<td style="font-family: Arial; font-size: 17px;"><?php echo $row['sala']; ?>
</td>
<td style="font-family: Arial; font-size: 17px;">
<?php
$result_t = mysqli_query($conn, "SELECT m.tipo
FROM `material` as m
INNER JOIN `ocorrencia_detalhe` as od on m.id = od.id_tipo
AND od.id_ocorrencia=".$row['id']);
while ($row2 = mysqli_fetch_assoc($result_t)): ?>
<?php echo $row2['tipo'] . " "; ?>
<?php endwhile;?>
</td>
</tr>
<?php endwhile; ?>
这是php代码:
var idocorrencia;
$(document).on("click","#listagem tr", function(e){
e.preventDefault();
idocorrencia = $(this).parent().attr("idlista");
$("#listagem caption").text($(this).text());
$.post( "historico.php", { idoc: idocorrencia })
});