0

I have a table in generated using PHP using data collected from MYSQL. How do I append a hyperlink to a row?

Here is the code for the dynamic table I am using:

 mydata = mysql_query($sql,$con);

 echo "<table id='name',table border=0>
<tr>
<th>Users</th>
<th>Status<th>
</tr>";
while($record = mysql_fetch_array($mydata)){
echo "<tr>";
echo "<td>" . $record['user_id'] . "</td>";
if (strtolower(trim($record['activity']))!=strtolower('LOGIN')){ 
echo "<td>" . $default1  . "</td>";
}else{

echo "<td>" . $default  . "</td>";

}

echo "</tr>";
}
echo "</table>";
;

I have tried appending a href="..." style="display:block;"> but cannot get it to work.

Sulexk
  • 61
  • 8

1 Answers1

1

Try echoing out a hyperlink.

echo "<a href='http://www.google.com/'>Google</a>";

If you want other functionality, such as clicking on a table row to work as a hyperlink, you would need to implement that in javascript as a table cell/row is not a hyperlink.

Jonathan Kuhn
  • 15,279
  • 3
  • 32
  • 43
  • Thanks Johnathon I will bear that in mind I was just trying to replicate this example http://stackoverflow.com/questions/10070232/how-to-make-a-cell-of-table-hyperlink – Sulexk Oct 29 '12 at 19:27
  • 1
    That was just an example, you need to replace the URL and text with something appropriate to your application, perhaps coming from the database query. – Barmar Oct 29 '12 at 19:44
  • The OP needs to address the fact that he can't create an object without mysqli or pdo, as well as missing `$`'s in front of variables. – jdstankosky Oct 29 '12 at 19:52