求~删除前确认框 php
我做的一个网站信息删除页delete.php给出超连接到delete2.php进行删除。想让用户在点击超连接之后,先弹出个确认框是否确定删除下面是我没有加确认框的代码,请...
我做的一个网站信息删除页
delete.php 给出超连接到delete2.php进行删除。
想让用户在点击超连接之后,先弹出个确认框 是否确定删除
下面是我没有加确认框的代码,请各位帮我改一下~ 谢谢了。
delete.php:
<h1>Select Desired Phone Record To Delete</h1>
<?php
include 'database_conn.php';
$sql = "SELECT phoneid, model, brand FROM product";
$queryresult = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_array($queryresult)){
$phoneid = $row['phoneid'];
$model = $row['model'];
$brand = $row['brand'];
echo "<a href = \"delete2.php?phoneid=$phoneid\">$model</a> $brand <br /> \n";
}
mysql_free_result($queryresult);
mysql_close($conn);
?>
delete2.php:
<?
$phoneid = $_GET['phoneid']; // need this to identify the particular record to delete
echo "<h1>Deleting record ... </h1>";
include 'database_conn.php'; // make db connection
$sql = "DELETE FROM product WHERE phoneid = $phoneid";
mysql_query($sql) or die (mysql_error());
echo "<h2>Record deleted</h2>";
mysql_close($conn);
echo "<p><a href=administratorarea.php>Back To Administrator Area</a></p>";
?>
1楼朋友的答案可以弹出确认框,但是不管按“确定”还是“取消”,记录都会被删除 展开
delete.php 给出超连接到delete2.php进行删除。
想让用户在点击超连接之后,先弹出个确认框 是否确定删除
下面是我没有加确认框的代码,请各位帮我改一下~ 谢谢了。
delete.php:
<h1>Select Desired Phone Record To Delete</h1>
<?php
include 'database_conn.php';
$sql = "SELECT phoneid, model, brand FROM product";
$queryresult = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_array($queryresult)){
$phoneid = $row['phoneid'];
$model = $row['model'];
$brand = $row['brand'];
echo "<a href = \"delete2.php?phoneid=$phoneid\">$model</a> $brand <br /> \n";
}
mysql_free_result($queryresult);
mysql_close($conn);
?>
delete2.php:
<?
$phoneid = $_GET['phoneid']; // need this to identify the particular record to delete
echo "<h1>Deleting record ... </h1>";
include 'database_conn.php'; // make db connection
$sql = "DELETE FROM product WHERE phoneid = $phoneid";
mysql_query($sql) or die (mysql_error());
echo "<h2>Record deleted</h2>";
mysql_close($conn);
echo "<p><a href=administratorarea.php>Back To Administrator Area</a></p>";
?>
1楼朋友的答案可以弹出确认框,但是不管按“确定”还是“取消”,记录都会被删除 展开
2个回答
展开全部
echo "<a href = \"delete2.php?phoneid=$phoneid\">$model</a> $brand <br /> \n";
把这行改改就行了。
echo "<a href = \"delete2.php?phoneid=$phoneid\" onclick=\"if(confirm('确实要删除此条记录吗?')) return true;else return false; \" >$model</a> $brand <br /> \n";
你的代码写得很简单,所以就用这个简单的方式了。链接上加了个onclick 事件。
把这行改改就行了。
echo "<a href = \"delete2.php?phoneid=$phoneid\" onclick=\"if(confirm('确实要删除此条记录吗?')) return true;else return false; \" >$model</a> $brand <br /> \n";
你的代码写得很简单,所以就用这个简单的方式了。链接上加了个onclick 事件。
展开全部
修改delete2.php
<script language=javascript>
if(!confirm('确实要删除此条记录吗?'))
{
window.location.href='delete.php';
}
</script>
<?
$phoneid = $_GET['phoneid']; // need this to identify the particular record to delete
echo "<h1>Deleting record ... </h1>";
include 'database_conn.php'; // make db connection
$sql = "DELETE FROM product WHERE phoneid = $phoneid";
mysql_query($sql) or die (mysql_error());
echo "<h2>Record deleted</h2>";
mysql_close($conn);
echo "<p><a href=administratorarea.php>Back To Administrator Area</a></p>";
?>
<script language=javascript>
if(!confirm('确实要删除此条记录吗?'))
{
window.location.href='delete.php';
}
</script>
<?
$phoneid = $_GET['phoneid']; // need this to identify the particular record to delete
echo "<h1>Deleting record ... </h1>";
include 'database_conn.php'; // make db connection
$sql = "DELETE FROM product WHERE phoneid = $phoneid";
mysql_query($sql) or die (mysql_error());
echo "<h2>Record deleted</h2>";
mysql_close($conn);
echo "<p><a href=administratorarea.php>Back To Administrator Area</a></p>";
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询