0
我已经做了一些sql记录,并有一个表来显示记录。我的问题是如何删除这条记录。我做了代码,但是错了。有什么建议么?从表中删除条目
表:
<?php
$result = mysql_query("SELECT id,onoma_pelati,tilefono,fax,email FROM visitors");
if (!$result) {
die("Problem...");
}
$fields_num=mysql_num_fields($result);
$counter = 1;
while($row = mysql_fetch_row($result))
{
echo "<tr>";
echo "<td>" . $counter . "</td>";
foreach($row as $cell)
{
echo "<th>$cell</th>";
}
echo '<td class="column">
<a href="delete.php?id=' . $row['id'] . '"><img src="images/icons/color/cross.png" /></a> </td></tr>';
$counter++;
}
mysql_free_result($result);
?>
和删除文件:
<?php
include('db_connection.php');
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = $_GET['id'];
$result = mysql_query("DELETE FROM visitors WHERE id=$id")
or die(mysql_error());
header("Location: showplio.php");
}
else
{
header("Location: addplio.php");
}
?>
只想问你是否在 - $ id-中删除文件。检查。 –
“代码却错了” - 究竟发生了什么?任何错误消息? – chrki
错误是:非法字符串偏移'id'在线:非法字符串偏移'id'在线:非法字符串偏移'id'在线 –