php中td标记内的href标记

时间:2013-08-15 09:11:25

标签: php hyperlink

代码的每一部分都可以正常工作,除了我想通过查询去下一页删除条目。 td的回显适用于文本,我希望将其作为链接。

<?php

$connect=mysql_connect("localhost","root","");
mysql_select_db("dbms_teacher",$connect);
$result=mysql_query("SELECT fname,lname,post,status FROM staffs");
echo "<table border=1>";
echo "<tr><td>First Name</td><td>Last Name</td><td>Post</td><td>Status</td><td>Edit      /Delete</td></tr>";
while ($row=mysql_fetch_array($result))
{

    echo "<tr>";
    echo "<td>" . $row['fname'] . "</td>";
    echo "<td>" . $row['lname'] . "</td>";
    echo "<td>" .$row['post']. "</td>";
    echo "<td>". $row['status']. "</td>";
    echo "<td> delete </td>"; //In this line, I want to hyperlink it to some other page
    echo "</tr>";
}
mysql_close($connect);
echo "</table>";
?>

6 个答案:

答案 0 :(得分:2)

$connect=mysql_connect("localhost","root","");
mysql_select_db("dbms_teacher",$connect);
$result=mysql_query("SELECT fname,lname,post,status FROM staffs");
echo "<table border=1>";
echo "<tr><td>First Name</td><td>Last Name</td><td>Post</td><td>Status</td><td>Edit          /Delete</td></tr>";
while ($row=mysql_fetch_array($result))
{

    echo "<tr>";
    echo "<td>" . $row['fname'] . "</td>";
    echo "<td>" . $row['lname'] . "</td>";
    echo "<td>" .$row['post']. "</td>";
    echo "<td>". $row['status']. "</td>";
    echo "<td><a href="delete.php?id=$row['id']">Delete</a></td>"; 
    echo "</tr>";
}
mysql_close($connect);
echo "</table>";

&GT;

答案 1 :(得分:0)

是的,您可以在PHP中使用HTML标记

"<td> delete </td>";

"<td><a href='http://yourlink'>delete</a></td>";

答案 2 :(得分:0)

这就足够了。

echo "<td><a href='delete.php'>delete</a></td>";

答案 3 :(得分:0)

你是说这个?

echo "<td><a href='index.php?action=etc'>delete</a> | <a href='index.php?action=etc'>edit</a></td>";

答案 4 :(得分:0)

"<td><a href='http://yourlink'>delete</a></td>";

从它的外观来看, 它应该是这样的。

答案 5 :(得分:-2)

2017-04-19 22:37:00.668 wanote[3667:493599] [Error]: unauthorized (Code: 0, Version: 1.12.0)
Optional(Error Domain=Parse Code=0 "unauthorized" UserInfo={error=unauthorized, NSLocalizedDescription=unauthorized, temporary=0})
Message from debugger: Terminated due to signal 15