Reputation: 1381
I am using the following code to display data in the form a table
echo "<table id='admin'>
<tr>
<th>ID</th>
<th> Name </th>
th>Email</th>
<th>Headline</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>" ;
echo "<td>" . $row['id'] ."</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['headline'] . "</td>";
echo "</tr>";
}
I have found many similar question but they mostly displayed hyperlink along with simple echo and their solution didn't work for me. I want that what ever data gets printed in this line i.e echo "<td>" . $row['name'] . "</td>";
should also behave as a hyperlink and redirect to another page. i tried to insert href link after but it showed syntax error. Any help would be appreciated
`
Upvotes: 0
Views: 2772
Reputation: 1876
echo "<td><a href='other.php'>" . $row['name'] . "</a></td>";
And also,
th>Email</th>
replace this with
<th>Email</th>
Upvotes: 0
Reputation: 1264
Like This
echo "<table id='admin'>
<tr>
<th>ID</th>
<th> Name </th>
th>Email</th>
<th>Headline</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>" ;
echo "<td><a href='#'>" . $row['id'] ."</a></td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['headline'] . "</td>";
echo "</tr>";
}
Upvotes: 2