-
Notifications
You must be signed in to change notification settings - Fork 26
/
classify.php
111 lines (100 loc) · 4.67 KB
/
classify.php
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
<?php
include_once("header.php");
?>
<script language="JavaScript">
function checkpost() {
if (myform.classname.value == "") {
alert("请输入分类名称");
window.location = 'add.php';
return false;
}
}
</script>
<?php
if ($_GET["Submit"]) {
$sql = "select * from ".$qianzui."account_class where classname='$_GET[classname]' and ufid='$_SESSION[uid]'";
$query = mysqli_query($conn,$sql);
$attitle = is_array($row = mysqli_fetch_array($query));
if ($attitle) {
$status_text = "此分类名称已存在!";
} else {
$sql = "insert into ".$qianzui."account_class (classname, classtype,ufid) values ('$_GET[classname]', '$_GET[classtype]',$_SESSION[uid])";
$query = mysqli_query($conn,$sql);
if ($query) {
$status_text = "<font color=#00CC00>添加成功!</font>";
echo "<meta http-equiv=refresh content='0; url=classify.php'>";
} else {
$status_text = "<font color=#FF0000>添加失败,写入数据库时发生错误!</font>";
echo "<meta http-equiv=refresh content='0; url=classify.php'>";
}
}
}
?>
<table align="left" width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor='#B3B3B3' class='table table-striped table-bordered'>
<tr>
<td bgcolor="#EBEBEB"> 新建分类</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<form id="myform" name="form1" method="get" onsubmit="return checkpost();">
分类名称:<input name="classname" type="text" id="classname" />
<select name="classtype" id="classtype" style="height:26px;">
<option value="1">收入</option>
<option value="2">支出</option>
</select><br /><br />
<input type="submit" name="Submit" value="新建" class="btn btn-default" />
<?php echo $status_text;
?>
</form>
</td>
</tr>
</table>
<table align="left" width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor='#B3B3B3' class='table table-striped table-bordered'>
<tr>
<td bgcolor="#EBEBEB"> 分类管理</td>
</tr>
</table>
<table width="100%" border="0" align="left" cellpadding="5" cellspacing="1" bgcolor='#B3B3B3' class='table table-striped table-bordered'>
<tr>
<th align="left" bgcolor="#EBEBEB">类别名称</th>
<th align="left" bgcolor="#EBEBEB"><font color='MediumSeaGreen'>收入</font></th>
<th align="left" bgcolor="#EBEBEB">操作</th>
</tr>
<?php
$sql = "select * from ".$qianzui."account_class where ufid='$_SESSION[uid]' and classtype='1'";
$query = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_array($query)) {
echo "<tr><td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>".$row['classname']."</font></td>";
if ($row['classtype'] == 1)
echo "<td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>收入</font></td>";
else
echo "<td align='left' bgcolor='#FFFFFF'><font color='red'>支出</font></td>";
echo "<td align='left' bgcolor='#FFFFFF'><a href='edit_classify.php?type=1&classid=".$row['classid']."'>修改</a> <a href='edit_classify.php?type=2&classid=".$row['classid']."'>转移</a> <a href='edit_classify.php?type=3&classid=".$row['classid']."'>删除</a></td>";
}
echo "</tr>";
?>
</table>
<table width="100%" border="0" align="left" cellpadding="5" cellspacing="1" bgcolor='#B3B3B3' class='table table-striped table-bordered'>
<tr>
<th align="left" bgcolor="#EBEBEB">类别名称</th>
<th align="left" bgcolor="#EBEBEB"><font color='red'>支出</font></th>
<th align="left" bgcolor="#EBEBEB">操作</th>
</tr>
<?php
$sql = "select * from ".$qianzui."account_class where ufid='$_SESSION[uid]' and classtype='2'";
$query = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_array($query)) {
echo "<tr><td align='left' bgcolor='#FFFFFF'><font color='red'>".$row['classname']."</font></td>";
if ($row['classtype'] == 1) {
echo "<td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>收入</font></td>";
} else {
echo "<td align='left' bgcolor='#FFFFFF'><font color='red'>支出</font></td>";
}
echo "<td align='left' bgcolor='#FFFFFF'><a href='edit_classify.php?type=1&classid=".$row['classid']."'>修改</a> <a href='edit_classify.php?type=2&classid=".$row['classid']."'>转移</a> <a href='edit_classify.php?type=3&classid=".$row['classid']."'>删除</a></td>";
echo "</tr>";
}
?>
</table>
<?php
include_once("footer.php");
?>