-3

除了我想通过查询进入下一页以删除条目外,代码的每个部分都可以正常工作。td 的回显适用于 text ,我想将其用作链接。

<?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>";
?>
4

6 回答 6

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>";

?>

于 2013-08-15T09:18:47.050 回答
0

You mean this?

echo "<td><a href='index.php?action=etc'>delete</a> | <a href='index.php?action=etc'>edit</a></td>";
于 2013-08-15T09:18:08.017 回答
0

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

"<td> delete </td>";

"<td><a href='http://yourlink'>delete</a></td>";
于 2013-08-15T09:17:27.163 回答
0

这就足够了。

echo "<td><a href='delete.php'>delete</a></td>";
于 2013-08-15T09:17:43.390 回答
0
"<td><a href='http://yourlink'>delete</a></td>";

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

于 2016-11-12T22:47:32.353 回答
-2
<td><a href="welcome.php"><?php echo $row['id'];?></a><td>
      here in this example<?php echo $row['id'];? is used
 by this we fetching  a value from db
and ha h h h h h h h h h h h h h h h h h h h h h standard blockquote is indented
> > A nested block
于 2017-04-19T13:56:15.217 回答