1
I’m doing a project where when I click on employees, it opens a page with a list of employees as you can see in the photo. I need the name of each employee to be clickable, so that later, I can open in another page the full employee form with all other fields (address, date of birth etc).
Here’s what I’ve tried so far (javascript and php/html code):
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
window.location = $(this).data("href");
});
});
<div class="table-responsive">
<?php
if (mysqli_num_rows($result) >0)
{
echo "<table border='1' class='table table-bordered width='100%' id='dataTable' cellspacing='0'>";
echo "<tr><th>Nome Trabalhador</th><th>Função</th><th>ID Trabalhador</th></tr>";
while ($row = mysqli_fetch_array ($result))
{
echo "<tr class='clickable-row' data-href='http://listar_funcionarios.php?id=" . $row['id_trabalhador'] . "/'>";
echo "<td>" . $row['nomeTrabalhador'] ."</td>";
echo "<td>" . $row['funcao'] ."</td>";
echo "<td>" . $row['id_trabalhador']."</td>";
echo "</tr>";
}
echo "</table>";
}
else
{
echo "No results to display!";
}
mysqli_close($link);
?>
</div>
Does this code not work? At first glance it seems to be right.
– Woss