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:[email protected] -->
<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%"> </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.cn