Location: PHPKode > projects > WebPOS > pda/admin/ModifyCategory.php
<?
session_start();
?><?
require_once("../../config/configDB.php");
require("../inc/yqrdb.php");
require("../inc/resizeToFile.func.php");
$mydb=new yqrdb($config_db);
//$r=$mydb->executeUpdate("insert into shopinfo(shopname) values('ddd')");
//$arr=$mydb->executeQuery("select * from category2");
//print_r($arr);
$id_parent;
$pos;
$nest_level;
$title;
$date_created;
$description;
$picture;
$active;
if(isset($_POST["action"]))
{
	$id=$_POST["id"];
	$id_parent=$_POST["id_parent"];
	$pos=$_POST["pos"];
	$nest_level=$_POST["nest_level"];
	$title=$_POST["title"];
	$description=$_POST["description"];
	$picture="";
	$active=$_POST["active"];
	
	$iconurl=$_FILES["picture"]["name"];
	$picture=basename($iconurl);
	$isUploaded=false;
	if(move_uploaded_file($_FILES["picture"]["tmp_name"],"./".$picture))
	{
		echo "ÉÏ´«³É¹¦!";
		$isUploaded=true;
			resizeToFile($picture,80,80,"icon".$picture,100);
			if(file_exists("../../web/img/categories/".$picture))
			{
				unlink("../../web/img/categories/".$picture);
			}
			copy("icon".$picture,"../../web/img/categories/".$picture);
			unlink("icon".$picture);
			unlink($picture);
	}

	
	
	//$sql="insert into ".$config_table["category"]."(id_parent,pos,nest_level,title,description,picture,date_created,active)".
	//"values ($id_parent,$pos,$nest_level,'$title','$description','$picture',now(),$active)";
	$sql="";
	if($isUploaded)
	{
		$sql="update ".$config_table["category"]." set id_parent=$id_parent,pos=$pos,nest_level=$nest_level,title='$title',description='$description',picture='$picture',active=$active where id=".$id;
	}else{
		$sql="update ".$config_table["category"]." set id_parent=$id_parent,pos=$pos,nest_level=$nest_level,title='$title',description='$description',active=$active where id=".$id;
	}
	$a=$mydb->executeUpdate($sql);
	if($a)
	{
		echo "·ÖÀàÐ޸ijɹ¦!";
	}
	
}
$id=$_GET["id"];
$sql="select * from ".$config_table["category"]." where id=$id";
$arr=$mydb->executeQuery($sql);
if(!empty($arr))
{
	$id_parent=$arr[0]["id_parent"];
	$pos=$arr[0]["pos"];
	$nest_level=$arr[0]["nest_level"];
	$title=$arr[0]["title"];
	$description=$arr[0]["description"];
	$picture=$arr[0]["picture"];
	$date_created=$arr[0]["date_created"];
	$active=$arr[0]["active"];
}
?>
<html><head>
<link href="../css/red_theme.css" rel="stylesheet" type="text/css" />
</head>
<body>
<? include("top_bar.php"); ?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table><tr><td>

<table width="371" border="0" cellpadding="3">
    <tr>
      <td width="93">Éϲã·ÖÀà±àºÅ</td>
      <td width="260">
<input name="id_parent" type="text" value="<?=$id_parent?>" /></td>
    </tr>
    <tr>
      <td>λÖÃ:</td>
      <td>
        <input name="pos" type="text" value="<?=$pos?>" />     </td>
    </tr>
    <tr>
      <td>Éî¶È:</td>
      <td>
        <input name="nest_level" type="text" value="<?=$nest_level?>" />     </td>
    </tr>
    <tr>
      <td>·ÖÀàÃû³Æ:</td>
      <td>
        <input type="text" name="title" value="<?=$title?>" />      </td>
    </tr>
    <tr>
      <td>ÃèÊö:</td>
      <td>
<textarea name="description" rows="5"><?=$description?></textarea></td>
    </tr>
    <tr>
      <td>Ñ¡ÔñͼƬ:</td>
      <td>
<input type="file" name="picture"  value="<?=$picture?>"/></td>
    </tr>
    
    <tr>
      <td>ÊÇ·ñÆôÓÃËü: </td>
      <td>
      <input name="active" type="radio" value="1" <? if($active==1){ ?> checked="checked" <? } ?> />
      yes
      <input type="radio" name="active" value="0" <? if($active==0){ ?> checked="checked" <? } ?> />
      no</td>
    </tr>
    <tr>
      <td><input type="submit" name="Submit" value="Ìá½»" />
      <input type="hidden" name="action" value="upload"/>
      <input type="hidden" name="id" value="<?=$id?>"/>
      </td>
      <td><input type="reset" name="Submit2" value="ÖØÖÃ" /></td>
    </tr>
  </table>
  </td><td>
  ²ÍƷͼƬ:<br/>
  <img src="../../web/img/categories/<?=$picture?>" /></td></tr></table>
 
</form>
</body>
</html>
Return current item: WebPOS