I am using an SQL query to populate an HTML table. The query runs fine and the table looks good. Now I want to make contents of the first column of each row a hyperlink. What is the best approach? My best guess is in the snippet below and was not successful.
...
$fields_num = mysqli_num_fields($result);
echo "<thead>";
echo "<tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysqli_fetch_field($result);
echo "<th>{$field->name}</th>";
}
echo "</tr>
";
echo "</thead>";
// printing table rows
while($row = mysqli_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell) {
if($cell[0]) {
echo "<td><a href="index2.php/$cell"></a></td>";
}
else
echo "<td>$cell</td>";
}
echo "</tr>
";
....