A PHP-file is creating a table with one column from a mysql-database. How could I make a window open which is showing the other columns of the database-row if I click on the row which I want to show?
If you don't understand:
-+ I create a table with php, which has 2 columns each row.
-+ The number of rows and the content are got from a mysql-database.
while ($data= mysqli_fetch_assoc($query))
{
echo "<tr>";
echo "<td style='text-align: center;'>" . $data['number'] . "</td>";
echo "<td>" . $data['name'] . "</td>";
echo "</tr>";
}
Now I want to make a clickable line out of this and this should open a window (the css is not the problem) which is showing other information to this clicked data.
For example I click on the 3rd row, a window should open and show me (for example) the number, the name, the second name, the hobbies and the sex. All this data is stored in the mysql-database.
while ($data= mysqli_fetch_assoc($query))
{
echo "<tr>";
echo "<td style='text-align: center;'>" . $data['number'] . "</td>"; echo "<td>" . $datensatz['name'] . "</td>"; ?>
<td>
<a href="yourprog.php?number=<? echo $data['number'] ?>&name=<? echo $data['name'] ?>" ></a>
</td><?
echo "</tr>";
}
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
while ($data= mysqli_fetch_assoc($query))
{
echo "<tr onclick=myfunction() id=". $data['unique_identifier'].">";
echo "<td style='text-align: center;'>" . $data['number'] . "</td>";
echo "<td>" . $datensatz['name'] . "</td>";
echo "</tr>";
}
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.