dongxianghui3709 2010-03-01 13:55
浏览 43
已采纳

删除PHP中的确认查看要删除的条目

I have a delete form wherein the user will enter the pnum to be deleted and then it will delete the corresponding record. But I want the user to atleast see what would be deleted so I tried this code, but it doesnt seem to work:

  <?php
  $con = mysql_connect("localhost","root","nitoryolai123$%^");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("Hospital", $con);
  $result = mysql_query("SELECT * FROM t2 WHERE PNUM='{$_POST["pnum"]}'");
?>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="DeletebyPnumIn.php" method="post" onSubmit="return confirm('Are you sure you want to delete "<?php echo $row["LASTNAME"]; ?>" )">

what might be the correct way of doing this?

  • 写回答

3条回答 默认 最新

  • dqthn68688 2010-03-01 14:14
    关注

    The code above does not include a line like:

    $row = fetch_array($result);
    

    You will need that for $row['LASTNAME'] to be set.

    Otherwise, it looks like your code should work. You don't say how it doesn't work though. And it's hard to tell if this is the first page where they enter the pnum or a second page where the deletion is being confirmed. If it's the first page, you won't have the pnum to run the query on.

    Instead of using javascript, you could have the original form post to a page that displays as much of the record information as you want to show the user. That page could have a simple "Are you sure..." form with buttons to delete or cancel.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂