php列出資料再用js 刪除資料

來源:互聯網
上載者:User

php列出資料再用js 刪除資料

<?php
include("../inc/inc.php");
islogin();
$Db = new Db();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>增加城市分類</title>
<!-- at:jimmy email:mailangel123@163.com -->

<LINK href="/themes/default/css/admin.css" rel=stylesheet>

<style type="text/css">
<!--
.STYLE2 {color: #666666}
-->
</style>
</head>
<body>

<table class="table_list" >
<form action="" name="myfm" id="myfm" >
 <caption   ><font class="red">
 {<?=PostGet('cname');?>}</font>地區管理
 </caption>
 
 <tr>
   <th width="32%">地區名稱</th>
   <th width="43%">排序位置</th>
   <th width="25%">&nbsp;</th>
 </tr>
 <?php
  $id = PostGet('aid');
  if( !is_numeric( $id ) )
  {
   exit;
  }
  $query = $Db->query("Select upid,cntitle,orderid,id from cn_loupan_city where upid='$id' order by orderid asc");
  if( $Db->rows( $query ) )
  {
   $row = $Db->fetch( $query ,0);
   
   foreach( $row as $array => $_v )
   {
 ?>
 
 <tr>
   <td class="align_c"><label>
     <input id="c_<?=$_v[3]?>" type="text" size="30" value="<?=$_v[1]?>" />
      </label></td>
   <td class="align_c"><label>
     <input id="s_<?=$_v[3]?>" type="text" size="20" value="<?=$_v[2]?>" />
      </label></td>
   <td class="align_c">
   <a href="javascript:sava('c_<?=$_v[3]?>','s_<?=$_v[3]?>',<?=$_v[3]?>);">儲存</a>|
   <a href="javascript:del('<?=$_v[3]?>');">刪除</a></td>
  </tr>
  
 <?php
   }
  }
 ?>
 </form>
</table>
<div style="text-align:center; margin:10px;"><a href="citymange.php">返回上一頁</a></div>

 <script language="javascript" >  
  function del(id)
 {
  if( confirm('確認刪除此條資訊?') )
  {
   location.href='public.php?action=deletes&id='+id+'&aid=<?=$id?>&cname=<?=PostGet('cname');?>';
  }
 
 }
 
 function sava(title,order,id)
 {
  if( confirm('確認你輸入資料無誤不嘍?') )
  {
   var cntitle = document.getElementById(title).value;
   var orderid = document.getElementById(order).value;
   if( "" == cntitle || cntitle.length>30 )
   {
    alert('地區名稱不可為空!');    
   }
   else if( isNaN( orderid ) )
   {
    alert("排序位置請輸入數字!");
   }
   else
   {
    location.href="public.php?action=edits&title="+cntitle+"&orderid="+orderid+"&id="+id+"&aid=<?=$id?>&cname=<?=PostGet('cname');?>";
   }   
  } 
 }
 </script>
</body>
</html>


public.php
function deletes()
 {
  $id = PostGet('id');
  $aid =PostGet('aid');
  $cn = urlencode(PostGet('cname'));
  if( !is_numeric( $id  ) )
  {
   exit;
  }
  else
  {
   $Db = new Db();
   try{
    $Db->query("Delete from cn_loupan_city where id='$id'");
    MessAge('操作成功','type.php?aid='.$aid.'&cname='.$cn);
   }catch( Execption $e){
    MessAge('操作失敗!');
   }
   $Db->close();
  }
 }

本站原創轉載註明 www.111cn.net

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.