【发布时间】:2011-10-05 16:24:48
【问题描述】:
我只是想在我的表格中添加一个按钮来删除特定的行,但与我的设置方式相比,我搜索的所有内容最终都是完全不同的方式。
<?php
// Connects to your Database and if it cant it dies
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// this selects the db
mysql_select_db("test", $con);
// this passes the query into the variable result
$result = mysql_query("SELECT * FROM items");
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Name</th>
<th>Quantity</th>
<th>Delete</th>
<tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['quantity'] . "</td>";
echo "<td>" . '<a href="delete.php">Delete</a>' . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
//end php
?>
<html>
<body>
<form action="insert.php" method="post">
Name: <input type="text" name="Name" />
Quantity: <input type="text" name="Quantity" />
<input type='submit' name='add' value='add' />
</form>
</body>
</html>
我想删除包含行的超链接。
【问题讨论】:
-
需要更多信息(即您希望删除发生在服务器端还是客户端?)。此外,无论第一个问题的答案如何,对 stackoverflow 的搜索都可能会产生该问题的现有解决方案。
标签: php html mysql delete-row