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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
<?php $thisFile= basename($PHP_SELF); $rowPerPage=20; if($_POST['work']){ $_GET['work']=$_POST['work'];} if($_POST['page']){ $_GET['page']=$_POST['page'];} if($_POST['menuID']){ $_GET['menuID']=$_POST['menuID'];} unset($_POST['work']); unset($_POST['page']); unset($_POST['menuID']); //echo " post work-> ".$_POST['work']." page-> ".$_POST['page']." menuID->".$_POST['menuID']."<br>"; if((!$_GET['page'])||($_GET['page']==1)){ $_GET['page']=1; $startRow=0; }else{ $startRow=($_GET['page']-1)*$rowPerPage; } //---------------------------UPDATE STATUS NEWS------------------- if($_POST['action']=='updateStatus'){ $_POST['date_start']=date("Y-m-d"); //$query="UPDATE tbl_act3_data SET first_page='".$_POST['first_page'][$_POST['EditID']]."' , date_start ='".$_POST['date_start']."' WHERE id= '".$_POST['EditID']."' "; $query="UPDATE tbl_act3_data SET first_page='".$_POST['first_page'][$_POST['EditID']]."' WHERE id= '".$_POST['EditID']."' "; mysql_query($query); } //---------------------------DELETE NEWS-------------------------------- if($_POST['action']=='DELETE'){ $query = "SELECT * FROM tbl_act3_pic WHERE model_data_id = '".$_POST['EditID']."' "; $result = mysql_query($query); while($data=mysql_fetch_assoc($result)){ if(file_exists($path_product.$data['pic_name'])){ @unlink($path_product_thb.$data['image_file']); @unlink($path_product.$data['image_file']); } } $query = "SELECT * FROM `tbl_act3_video` WHERE model_data_id = '".$_POST['EditID']."' "; $result = mysql_query($query); while($data=mysql_fetch_assoc($result)){ if(file_exists($path_product.$data['pic_name'])){ @unlink($path_product.$data['image_file']); } } $query = "DELETE FROM `tbl_act3_video` WHERE model_data_id ='".$_POST['EditID']."' "; mysql_query($query); $query = "DELETE FROM tbl_act3_pic WHERE model_data_id ='".$_POST['EditID']."' "; mysql_query($query); $query="DELETE FROM tbl_act3_data WHERE id= '".$_POST['EditID']."' "; mysql_query($query);
} //-----------------------SELECT NEWS DATA --------------------------------- if($_POST['selectCateID']){ $query="SELECT * FROM tbl_act3_data WHERE cate_id='".$_POST['selectCateID']."' ORDER BY date_post DESC "; }else{ $query="SELECT * FROM tbl_act3_data ORDER BY date_post DESC "; } $queryLimit = $query." LIMIT $startRow, $rowPerPage "; $result=mysql_query($queryLimit); $result2=mysql_query($query); $xrow=mysql_num_rows($result2); $totalPage=ceil($xrow/$rowPerPage); $query="SELECT * FROM tbl_act_category ORDER BY date_post DESC "; $resultCategory=mysql_query($query); ?> <!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=utf-8" /> <title>Untitled Document</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script language="javascript"> //-------------------------------- function FormValid(){ if(document.form1.cate_name.value==''){ alert("กรุณาใส่ชื่อ หมวดสินค้า "); return false; }else { document.form1.action.value = 'AddPack'; } } //--------------------------------------------------- function EditThis(ids,nums){ document.form1.EditID.value=ids; document.form1.num.value=nums; document.form1.action.value = 'EditCate'; document.form1.submit(); } //--------------------------------------------------- function DeleteThis(ids,img){ if(confirm('ต้องการลบรายการนี้')){ document.form1.EditID.value=ids; document.form1.action.value = 'DELETE'; document.form1.img.value = img; document.form1.submit(); }else{ return false; } } //--------------------------------------------------- function changePage(work,menuID,page){ document.form1.work.value=work; document.form1.menuID.value=menuID; document.form1.page.value=page; document.form1.submit(); } </script> </head>
<body> <form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1" > <input type="hidden" name="work" /> <input type="hidden" name="menuID" /> <input type="hidden" name="page" /> <table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr> <td class="txt10-black"><table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr class="txt10-black"> <td width="46%" height="30" align="left" bgcolor="#FFFFFF" class="txt10-black" ><img src="images/black_icon/16x16/notepad_2.png" width="16" height="16" hspace="5" align="absmiddle" />ข่าวและกิจกรรม <input type="hidden" name="action" id="action" /> <input type="hidden" name="EditID" id="EditID" /> <input type="hidden" name="img" id="img" /> <a href="main.php?work=articleAdd"><img src="images/black_icon/16x16/sq_plus.png" width="16" height="16" hspace="5" border="0" align="absmiddle" />เพิ่มข่าวสาร</a></td> <td width="54%" align="right" bgcolor="#FFFFFF" class="txt10-black" >กรุณาเลือกหมวดข่าวสาร <select name="selectCateID" id="selectCateID" onchange="document.form1.submit()"> <option value="">--ข่าวสารทั้งหมด--</option> <?php while($cate=mysql_fetch_assoc($resultCategory)){?> <option value="<?php echo $cate['id']?>" <?php if($_POST['selectCateID']==$cate['id']){ echo "selected";}?>><?php echo $cate['category_name']?></option> <?php }?> </select></td> </tr> <tr> <td colspan="2" align="left" class="txt10-black"><table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td align="center" bgcolor="#E1E1E1"> </td> <td colspan="2" bgcolor="#E1E1E1"> </td> <td width="66" align="center" bgcolor="#E1E1E1">รายละเอียด</td> <td width="39" align="center" bgcolor="#E1E1E1">ลบ</td> </tr> <?php $n=1;while($data=mysql_fetch_assoc($result)){ ?> <tr> <td width="16" align="center"><img src="images/black_icon/16x16/rnd_br_next.png" width="16" height="16" /></td> <td width="509"><?php echo $data['topic']?> </td> <td width="83"><label for="select"></label> <select name="first_page[<?php echo $data['id']?>]" onchange="document.form1.action.value='updateStatus';document.form1.EditID.value='<?php echo $data['id']?>';document.form1.submit();"> <option value="1" <?php if($data['first_page']=='1') echo "selected";?>>แสดงทันที</option> <option value="0" <?php if($data['first_page']=='0') echo "selected";?>>ไม่แสดง</option> </select></td> <td align="center"> <a href="main.php?work=articleAdd¤tID=<?php echo $data['id']?>"><img src="images/black_icon/16x16/zoom.png" width="16" height="16" border="0" /></a> </td> <td align="center"> <a href="javascript:void(0)" onclick="DeleteThis('<?php echo $data['id']?>','<?php echo $data['bannerFile']?>')" title="ลบ รายการนี้"> <img src="images/black_icon/16x16/delete.png" width="16" height="16" border="0" /></a></td> </tr> <tr> <td height="1" colspan="5" align="center" bgcolor="#E1E1E1"></td> </tr> <?php $n++; }?> </table> <br /> Page : <!--<a href="main.php?work=<?php echo $_GET['work']?>&MenuID=<?php echo $_GET['MenuID']?>&page=<?php echo $i?>" > --> <?php for($i=1;$i<=$totalPage;$i++){ ?> <a href="#" onclick="changePage('<?php echo $_GET['work']?>','<?php echo $_GET['MenuID']?>','<?php echo $i?>')" > <?php if($i==$_GET['page'])echo "<b><font size='+1'> "; echo $i." "; if($i==$_GET['page'])echo "</font></b>"; ?> </a> <?php } //echo "<br>".$_POST['page'];?></td> </tr> </table></td> </tr> </table> </form> <table border="0" width=""> <tr><td> </td></tr> </table> </body> </html>
|