Repository navigation
Expand file tree
/
Copy pathedit_classify.php
More file actions
129 lines (129 loc) · 6.65 KB
/
Copy pathedit_classify.php
File metadata and controls
129 lines (129 loc) · 6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
include_once("header.php");
?>
<table align="center" width="640" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="40" height="25"> </td>
<td> </td>
</tr>
<tr>
<td width="40" height="85"> </td>
<td align="left" valign="top">
<?php
//查询当前分类信息
$sql = "select * from ".$qianzui."account_class where classid='$_GET[classid]' and ufid='$_SESSION[uid]'";
$query = mysqli_query($conn,$sql);
$cuclass = mysqli_fetch_array($query);
//执行操作--修改分类名称
if ($_GET['Submit']) {
$sql = "update ".$qianzui."account_class set classname= '$_GET[classname2]' where classid='$_GET[classid]' and ufid='$_SESSION[uid]'";
$query = mysqli_query($conn,$sql);
if ($query) {
echo "分类名称修改成功!</td></tr></table> 2秒后自动返回<meta http-equiv=refresh content='2; url=classify.php'>";
exit();
} else {
echo "修改分类名称,执行数据库操作时失败!</td></tr></table> 2秒后自动返回<meta http-equiv=refresh content='2; url=classify.php'>";
exit();
}
}
//执行操作--转移分类
if ($_GET['Submit2']) {
$sql = "select * from ".$qianzui."account where acclassid= '$_GET[classid]' and jiid='$_SESSION[uid]'";
$query = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_array($query)) {
$sql = "update ".$qianzui."account set acclassid= '$_GET[toclassid]' where acid= '$row[acid]' and jiid='$_SESSION[uid]'";
mysqli_query($conn,$sql);
}
echo "转移完成,你可以查询此分类下是否还有记录,已确认是否全部转移成功!</td></tr></table> 2秒后自动返回<meta http-equiv=refresh content='2; url=classify.php'>";
exit();
}
//执行操作--删除分类
if ($_GET['Submit3']) {
$sql = "select * from ".$qianzui."account where acclassid='$_GET[classid]' and jiid='$_SESSION[uid]'";
$query = mysqli_query($conn,$sql);
if ($row = mysqli_fetch_array($query)) {
echo "<font color='red'>无法删除!在此分类下有账目,请将账目转移到其他分类。</font></td></tr></table> 2秒后自动返回<meta http-equiv=refresh content='2; url=classify.php'>";
exit();
} else {
$sql = "delete from ".$qianzui."account_class where classid=".$_GET['classid'];
if (mysqli_query($conn,$sql))
echo "分类删除成功!</td></tr></table> 2秒后自动返回<meta http-equiv=refresh content='2; url=classify.php'>";
else
echo "<font color='red'>删除失败!从数据库中删除时返回失败!</font></td></tr></table> 2秒后自动返回<meta http-equiv=refresh content='2; url=classify.php'>";
exit();
}
}
//根据操作判断要显示内容
if ($_GET['type'] == "1") {
?>
<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><form id="form1" name="form1" method="get" action="">
<label>将[<font color="red"><?php echo $cuclass['classname'];
?></font>]修改为
<input name="classname2" type="text" id="classname2" value="<?php echo $cuclass['classname'];
?>" />
</label>
<label>
<input type="submit" name="Submit" value="修改" />
</label>
<input name="classid" type="hidden" id="classid" value="<?php echo $_GET['classid'];
?>" />
</form>
</td>
</tr>
</table>
<?php
} elseif ($_GET['type'] == "2") {
?>
<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><form id="form2" name="form2" method="get" action="">
将[<font color="red"><?=$cuclass['classname'] ?></font>]
<label>转移到
<select name="toclassid" id="toclassid">
<?php
$sql = "select * from ".$qianzui."account_class where classtype=$cuclass[classtype] and ufid='$_SESSION[uid]'";
$query = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_array($query)) {
echo "<option value='$row[classid]'>$row[classname]</option>";
}
?>
</select>
</label>
<label>
<input type="submit" name="Submit2" value="转移" />
</label>
<input name="classid" type="hidden" id="classid" value="<?=$_GET['classid'] ?>" />
</form>
</td>
</tr>
</table>
<?php
} elseif ($_GET['type'] == "3") {
?>
<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>删除前请将此分类转移到其他分类,否则无法删除</td>
</tr>
<tr>
<td><form id="form3" name="form3" method="get" action="">
<label>
<input type="submit" name="Submit3" value="删除" />
</label>
<input name="classid" type="hidden" id="classid" value="<?=$_GET['classid'] ?>" />
</form>
</td>
</tr>
</table>
<?php
} else {
echo "参数错误!";
}
?>
</td>
</tr>
</table>
<?php
include_once("footer.php");
?>