javascript - How to create a clickable html table with php?
245
I just tried creating a clickable table to show more information by clicking on a table row.
This is my code for the table creation:
while ($data= mysqli_fetch_assoc($query))
{
echo "<tr>";
echo "<td style='text-align: center;'>" . $data['number'] . "</td>";
echo "<td>" . $data['name'] . "</td>";
echo "</tr>";
}
How can I create a click event on every specific table row which calls a function with the unique id of the entry?
Answer
Solution:
There's lots of ways you can go about doing this. The simplest way here would be to add an onclick listener to the row
And myfunction sends an ajax request or you preload the data and just display the data. The id serves as either mysql where clause or as a getter in case the data is preloaded
Answer
Solution: