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
|
<?php // Status Package Module $status_module=select_query("status_module","cms_status_module","id","2"); if($status_module[0]!=1) { fieldset_no_module(); } $navig['news']="ข่าวประชาสัมพันธ์ (ภายในหน่วยงาน) ย้อนหลัง"; navigator($navig); echo"<br>"; bar_header("ข่าวย้อนหลัง"); // Bar_Header fieldset_top("ข่าวประชาสัมพันธ์"); if($p_startrow!="") { $startrow=trim($p_startrow); } if($p_id_news!="") { $id_news=trim($p_id_news); } if($p_id_hide!="") { $id_hide=trim($p_id_hide); } if($p_id_show!="") { $id_show=trim($p_id_show); } if($p_id_sub!="") { $id_sub=trim($p_id_sub); }
if($_SESSION[admin_web]=="admin" or (id_top_permission("news"))){ // ####news if($id_news!=""){ $sql1="select pic1,pic2,pic3,pic4,files from cms_news where id='$id_news'"; $result1=mysql_query($sql1); $data1=mysql_fetch_row($result1); if($data1[0]!="") { unlink("$_SESSION[web_name]/mainfile/$data1[0]"); } if($data1[1]!="") { unlink("$_SESSION[web_name]/mainfile/$data1[1]"); } if($data1[2]!="") { unlink("$_SESSION[web_name]/mainfile/$data1[2]"); } if($data1[3]!="") { unlink("$_SESSION[web_name]/mainfile/$data1[3]"); } if($data1[4]!="") { unlink("$_SESSION[web_name]/mainfile/$data1[4]"); } $sql = "delete from cms_news where id='$id_news'"; $result = mysql_query($sql); } // #####Hide - Show cms_news if($id_hide!=""){ $sql="UPDATE cms_news SET status='0' WHERE id='$id_hide'"; mysql_query($sql); include('coremain/connec_out.php'); $sql="UPDATE cms_news SET status='0' WHERE id='$id_hide' and id_tumbon='$_SESSION[id_tumbon]'"; $result=mysql_query($sql); //refresh_page(0,"index.php?mod=news_old&id_type=1&id_sub=99999&path=news"); mysql_close($handle_out); include("$_SESSION[web_name]/connect.php"); } if($id_show!=""){ $sql="UPDATE cms_news SET status='1' WHERE id='$id_show'"; mysql_query($sql); include('coremain/connec_out.php'); $sql="UPDATE cms_news SET status='1' WHERE id='$id_show' and id_tumbon='$_SESSION[id_tumbon]'"; $result=mysql_query($sql); // refresh_page(0,"index.php?mod=news_old&id_type=1&id_sub=99999&path=news"); mysql_close($handle_out); include("$_SESSION[web_name]/connect.php"); } }
include('coremain/connec_out.php'); // Delete News if($id_news!="") { $sql = "delete from cms_news where id='$id_news' and id_tumbon='$_SESSION[id_tumbon]'"; $result = mysql_query($sql) or die(mysql_error()); } mysql_close($handle_out);
include("$_SESSION[web_name]/connect.php");
$row_per_page = 10; //กำหนดจำนวนบรรทัดต่อหน้า if($_SESSION[admin_web]=="admin" or (id_top_permission("news"))){ $query="select id,LEFT(topic,100) as topic,date_post,status from cms_news WHERE id_sub='$id_sub' order by id desc"; $query_count="select count(id) from cms_news WHERE id_sub='$id_sub' order by id desc"; }else{ $query="select id,LEFT(topic,100) as topic,date_post,status from cms_news WHERE id_sub='$id_sub' and status='1' order by id desc"; $query_count="select count(id) from cms_news WHERE id_sub='$id_sub' and status='1' order by id desc"; }
if (empty($startrow)) { //ลองตรวจดูว่าค่าแถวเริ่มต้นที่จะแสดงไม่ได้กำหนดหรือเปล่า ถ้าไม่ได้กำหนด จะกำหนดให้เป็น 0 $startrow = 0; }
$result = mysql_query($query_count); $row = mysql_fetch_array($result);
$total_row = $row[0]; //ได้ค่าจำนวนบรรทัดทั้งหมดที่จะต้องแสดง $total_page = intval((($total_row-1)/$row_per_page)+1); //หาค่าจำนวนหน้าทั้งหมดที่ต้องแสดง $current_page = (($startrow)/$row_per_page)+1; //หาว่าหน้าที่แสดงอยู่ปัจจุบันเป็นหน้าที่เท่าไหร่ $count=0; $result = mysql_query($query." LIMIT $startrow,$row_per_page"); while ($data = mysql_fetch_array($result)) { if($count%2==0) $bgcolor="eeeeee"; else $bgcolor="dddddd"; $count++; echo"<br><table width='100%' border='0' cellpadding='0' cellspacing='0' bgcolor=$bgcolor>"; // เนื้อหาข่าว echo" <tr height='25'>"; echo"<td width='70%'>"; echo "<img src='coremain/images/topic.gif'> <a href='index.php?id_news=$data[id]&mod=news_old_full&path=news'>$data[topic]</a><td>"; echo"<td align=right>"; if($_SESSION[admin_web]=="admin" or (id_top_permission("news"))){ // show - hide if($data[status]=='1'){ echo "<a href='index.php?mod=news_old&id_hide=$data[id]&id_sub=$id_sub&path=news'><img SRC='coremain/images/show.gif' border='0' title='ซ่อน'></a>"; }else{ echo "<a href='index.php?mod=news_old&id_show=$data[id]&id_sub=$id_sub&path=news'><img SRC='coremain/images/hide.gif' border='0' title='แสดง'></a>";} // update box_update("index.php?mod=news_old_update&id_update=$data[id]&startrow=$startrow&id_sub=$id_sub&path=news"); // del echo" <a href='index.php?mod=news_old&id_news=$data[id]&startrow=$startrow&id_sub=$id_sub&path=news' onclick='return del_popup();'><img src='coremain/images/del1.gif' border='0' title='ลบข้อมูลนี้'></a>"; } echo"</td>";
echo"</tr>"; echo"</table>"; } if ($total_page>1) { //ตรวจดูว่าถ้าจำนวนหน้าทั้งหมดมีไม่เกิน 1 หน้า ต้องแสดงบรรทัดที่จะให้เลือกหน้า $previous_page = $current_page-1; //หาว่าหน้าก่อนหน้าปัจจุบันคือหน้าอะไร $next_page = $current_page+1; //หาว่าหน้าถัดจากหน้าปัจจุบันคืออะไร if ($previous_page >0) { //ถ้าหน้าก่อนหน้าติดลบหรือเป็นศูนย์แสดงว่าไม่สามารถแสดงหน้าก่อนหน้าได้ $new_startrow = $startrow - $row_per_page ; $left_page_show = "<A HREF=index.php?mod=news_old&startrow=$new_startrow&path=news&id_sub=$id_sub><b>ก่อนหน้า</b></A> " ; } else { $left_page_show = "<b><font color='$datatm[color1]'>ก่อนหน้า</font></b> "; } if ($next_page > $total_page) { //ถ้าหน้าถัดไป มากกว่าจำนวนหน้าทั้งหมด แสดงว่าไม่สามารถแสดงหน้าถัดไปได้ $right_page_show = " <b><font color='$datatm[color1]'>ต่อไป</font></b>"; } else { $new_startrow = $startrow + $row_per_page; $right_page_show = " <A HREF=index.php?mod=news_old&startrow=$new_startrow&path=news&id_sub=$id_sub><b>ต่อไป</b></A>"; }
$middle_page_show = ""; for ($i=1;$i<=$total_page;$i++) { //วนลูปแสดงหน้าทั้งหมด if ($i == $current_page) { //ถ้าหน้าที่พิมพ์เป็นหน้าเดียวกับหน้าปัจจุบัน แสดงให้ไม่สามารถคลิ๊กได้ $middle_page_show .= " <font color='ff0000'><b>[</font><font color='$datatm[color1]'>$i</font><font color='ff0000'>]</font></b> "; } else { $new_startrow = (($i-1)*$row_per_page); $middle_page_show .= " <A HREF=index.php?mod=news_old&startrow=$new_startrow&path=news&id_sub=$id_sub> <b>$i</b> </A> "; } } $page_show = $left_page_show . $middle_page_show . $right_page_show; } else { $page_show = ""; } echo "<br> <font color='0000ff'>$page_show</font>"; fieldset_down(); ?>
|