So I have a pop up box that shows when I click on the table row and on that box should be the values from that table row but instead is only showing the last inserted row from db.
Here is the HTML:
<tbody>
<?php
$conn = mysqli_connect("localhost", "root", "", "fix_in_time");
$result = mysqli_query($conn, "SELECT * FROM `ocorrencia` as o INNER JOIN
`insere_material` as im ON o.id = im.id");
$num = 1;
while($row = mysqli_fetch_assoc($result)):
?>
<tr id="table_row_<?php echo $num; ?>" onclick="hide('table_row_<?php echo
$num; ?>'), window.location= '#bg'">
<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 echo $row['tipo']; ?>
</td>
</tr>
<?php endwhile; ?>
<script src="scripts/table.js"></script>
<div id="bg"></div>
<div class="box">
<a href="" id="close">X</a>
<p id="rcorners1"></p>
<p id="Title1">Data</p>
<p id="Title2">Sala</p>
<p id="Title3">Tipo</p>
<p id="Title4">Descrição</p>
<?php
$result1 = mysqli_query($conn, "SELECT * FROM `ocorrencia` as o INNER JOIN `insere_material` as im ON o.id = im.id");
while ($row = mysqli_fetch_assoc($result1)): ?>
<p class="data"><?php echo $row['data']; ?></p>
<p class="sala"><?php echo $row['sala']; ?></p>
<p class="tipo"><?php echo $row['tipo']; ?></p>
<textarea readonly id="descricao"><?php echo $row['descricao'];?></textarea>
<?php endwhile;?>
the pop up click on table row is this:
<tr id="table" onclick="hide(), window.location= '#bg'">
<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 echo $row['tipo']; ?>
</td>
</tr>
JS:
function hide(tableRow){
var x = document.getElementById(tableRow);
if(x.style.display === "none"){
x.style.display = "block";
}else{
x.style.display = "none";
}
}