How can PHP be used to dynamically generate clickable URLs in tables?
To dynamically generate clickable URLs in tables using PHP, you can use a loop to iterate through your data and output table rows with clickable links. You can concatenate the URL with the specific data value to create dynamic links. This allows you to generate clickable URLs based on the data in your table.
<?php
// Sample data
$data = array(
array('id' => 1, 'name' => 'John'),
array('id' => 2, 'name' => 'Jane'),
array('id' => 3, 'name' => 'Alice')
);
// Output table with clickable URLs
echo '<table>';
foreach ($data as $row) {
echo '<tr>';
echo '<td><a href="http://example.com/user.php?id=' . $row['id'] . '">' . $row['name'] . '</a></td>';
echo '</tr>';
}
echo '</table>';
?>