www.gusucode.com > 仿51.com的php源码 1.1 > admin/admin_city_add.php

    <?php 
include("ck_login.php");
include("../include/dbclass.php"); ?>
<?php
$act=$_GET["act"];
if ($act=="add")
{ 
$pratentid=$_POST["pratentid"];
$cityname=$_POST["cityname"];
//echo($pratentid);
//echo($cityname);
$db = new DbConn();
//$db->mysql($dbhost,$dbuser,$dbpassword,$dbname);
//$db->createcon();

$sql="insert into city (cityname,pratentid) values('$cityname','$pratentid')";
$db->Execute($sql);
echo "<script >alert('增加成功!');location.href='admin_city_add.php?p_id=$pratentid';</script>";

}
?>
<?php 
if ($act=="dels")
{
$id=$_GET["id"];
$p_id=$_GET["p_id"];
$db = new DbConn();
$sql="delete  from city where id='$id'";
$db->Execute($sql);
echo "<script >alert('删除成功!');location.href='admin_city_add.php?p_id=$p_id';</script>";

}
?>
<?php 
if ($act=="modfiysave")
{
$id=$_GET["id"];
$cityname=$_POST["cityname"];
$pratentid=$_POST["pratentid"];
$db = new DbConn();
$sql="update city set cityname='$cityname',pratentid='$pratentid' where id='$id'";
$db->Execute($sql);
echo "<script >alert('修改成功!');location.href='admin_city_add.php?p_id=$pratentid';</script>";
}
?>
<!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>
<link href="admin_style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {color: #000000}
-->
</style>
</head>

<body><table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align=center>
<tr align="center">
    <td height=25 colspan=2 class="topbg"><strong class="title STYLE1"><a href="admin_city_add.php">管理地区</a></strong></tr>
<tr><td>
</td>
</tr>
</table>
<br>
<?php if ($act=="modfiy")
{
?>
<form id="form1" name="form1" method="post" action="?act=modfiysave&id=<?php echo ($_GET["id"]);?>">
<?php
$db=new DbConn();
$id=$_GET["id"];
$sql="select * from city where id='$id'";
$v=$db->getRs($sql);

}
else
{
?>
<form id="form1" name="form1" method="post" action="?act=add">
<?php
}
?>
<table width="100%" height="14%" border="0" class="border">
  <tr>
    <td width="27%" height="32" align="center" class="tdbg">父ID:</td>
    <td width="73%" class="tdbg"><input name="pratentid" type="text" class="STYLE1" id="pratentid"  <?php if ($act=="modfiy"){?> value="<?php echo $v[2];?>" <?php }else { ?>value="<?php if ( $_GET["p_id"]==""){ echo("0");}else{ echo($_GET["p_id"]);}  ?>" <?php }?> size="15" maxlength="8" /></td>
  </tr>
  <tr>
    <td align="center" class="tdbg">名称:</td>
    <td class="tdbg"><input name="cityname" type="text" class="STYLE1" id="cityname" <?php if ($act=="modfiy"){?> value="<?php echo $v[1];?>" <?php }?> maxlength="12" /></td>
  </tr>
  <tr>
    <td align="center" class="tdbg">&nbsp;</td>
    <td class="tdbg"><label>
      <input name="Submit" type="submit" class="STYLE1" value="确定" />
    </label></td>
  </tr>
</table>

</form><br />
<table width="100%" border="0" class="border">
  <tr>
    <td width="5%" align="center" class="tdbg"><strong>ID</strong></td>
    <td width="16%" align="center" class="tdbg"><strong>城市名称</strong></td>
    <td width="13%" align="center" class="tdbg"><strong>父类ID</strong></td>
    <td width="16%" align="center" class="tdbg"><strong>查看子类</strong></td>
    <td width="16%" align="center" class="tdbg"><strong>操作</strong></td>
  </tr>
  <?php
  $db=new DbConn();
  $str_p_id=$_GET["p_id"];
  if ($str_p_id=="")
  {
  $sql="select * from city where pratentid='0'";
  }
  else
  {
   $sql="select * from city where pratentid='$str_p_id'";
   }
  
  $result=$db->query($sql);
 while ($row=@mysql_fetch_array($result)) {
	?>

  <tr>
    <td height="25" align="center" class="bgcolor"><?php echo ($row["id"]);?></td>
	<td align="center" class="bgcolor"><?php echo ($row["cityname"]);?></td>
    <td align="center" class="bgcolor"><?php echo ($row["pratentid"]);?></td>
	 <td align="center" class="bgcolor"><a href="?p_id=<?php echo ($row["id"]);?>">查看子类</a></td>
    <td align="center" class="bgcolor"><a href="?act=modfiy&id=<?php echo ($row["id"]);?>">修改</a>  <a href="?act=dels&id=<?php echo ($row["id"]);?>&p_id=<?php echo ($row["pratentid"]);?>">删除</a></td>
  </tr>
<?php
}
$db->free_result($result);
?>

</table>
</body>
</html>