Announcement.php


SUBMITTED BY: Guest

DATE: Sept. 23, 2014, 7:35 p.m.

FORMAT: PHP

SIZE: 11.0 kB

HITS: 826

  1. <?
  2. require_once("functions.php");
  3. global $action,$userinfo;
  4. chkuserlogin($userinfo);
  5. $userinfo['userlevel']=1;
  6. $table="announcements";
  7. fheader();
  8. ?>
  9. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  10. <link href="includes/styles.css" rel="stylesheet" type="text/css">
  11. <table width="757" border="0" align="center" cellpadding="4" bordercolor="#333333" bgcolor="#FFFFFF" class="default">
  12. <tr>
  13. <td align="center" bgcolor="#999999">
  14. <font color="#FFFFFF" size="4"><b>Announcement
  15. Maintenance</b></font>
  16. </td>
  17. </tr>
  18. <?
  19. function flist() {
  20. global $action,$url,$table,$sql,$recperpage,$search,$navinfo,$userinfo,$recperpage,$search;
  21. $searchfor = initobj("searchfor");
  22. $searchvalue = initobj("searchvalue");
  23. $arrsearch = Array("Announcement"=>"announcement");
  24. $condition = ($searchfor!="") ? "where $searchfor like '%$searchvalue%'" : "";
  25. $sql = "select * from $table $condition";
  26. ?>
  27. <tr>
  28. <td align="center" valign="top">
  29. <table width="100%" cellpadding="4" cellspacing="2" class="default">
  30. <tr>
  31. <td colspan="2" align="center">
  32. <table width="100%" border="1" cellpadding="1" cellspacing="0" class="default">
  33. <tr>
  34. <td align="center" valign="middle" bgcolor="#CCCCCC">
  35. <input type="button" name="add" value="Add Item" onclick="location='<?=$url?>?action=formadd&uid=0'" />
  36. <input type="button" name="listall" value="List All" onclick="location='<?=$url?>'" />
  37. </td>
  38. </tr>
  39. </table>
  40. </td>
  41. </tr>
  42. <tr>
  43. <td colspan="2" align="center">
  44. <table width="100%" border="1" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF" class="default">
  45. <tr>
  46. <td width="100%">
  47. <table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF" class="default">
  48. <form name="frm" method="post" action="<?=$url?>">
  49. <tr>
  50. <td width="100%" colspan="3">
  51. <table width="100%" border="0" cellpadding="0" cellspacing="0" class="default">
  52. <tr>
  53. <td width="15%">
  54. Search
  55. </td>
  56. <td width="7%" align="left">
  57. <select name="searchfor">
  58. <? foreach ($arrsearch as $key=>$value) {
  59. if ($searchfor==$value) {
  60. $tag = "selected";
  61. $search = $key;
  62. } else
  63. $tag = "";
  64. ?>
  65. <option value="<?=$value?>" <?=$tag?>>
  66. <?=$key?>
  67. </option>
  68. <? } ?>
  69. </select>
  70. </td>
  71. <td width="51%" align="left">
  72. <b>&nbsp;&nbsp;=</b>
  73. <input type="text" name="searchvalue" size="12" />
  74. <input type="submit" name="Submit" value="Submit" />
  75. <input type="hidden" name="action" value="list" />
  76. </td>
  77. <td width="27%" align="right">&nbsp;
  78. </td>
  79. </tr>
  80. </table>
  81. </td>
  82. </tr>
  83. </form>
  84. </table>
  85. </td>
  86. </tr>
  87. </table>
  88. </td>
  89. </tr>
  90. <tr>
  91. <td colspan="2">
  92. <table width="100%" cellpadding="3" cellspacing="1" class="default">
  93. <?
  94. $result = mysql_query($sql);
  95. $row = mysql_fetch_array($result);
  96. if (is_array($row)) {
  97. ?>
  98. <tr>
  99. <td width="7%" height="17" align="left" bgcolor="#CCCCCC">
  100. <b>ID</b>
  101. </td>
  102. <td width="37%" height="17" align="left" bgcolor="#CCCCCC">
  103. <b>Announcement</b>
  104. </td>
  105. <td width="56%" height="17" bgcolor="#CCCCCC">&nbsp;
  106. </td>
  107. </tr>
  108. <?
  109. $ct = 0;
  110. do {
  111. $id = $row['id'];
  112. $announcement = $row['announcement'];
  113. $ct++;
  114. if ($ct % 2 == 0)
  115. $bgcolor = "white";
  116. else
  117. $bgcolor = "";
  118. ?>
  119. <tr bgcolor="<?=$bgcolor?>">
  120. <td width="7%">
  121. <?=$id?>
  122. </td>
  123. <td width="37%">
  124. <a href="<?=$url?>?action=formedit&uid=<?=$id?>"><u>
  125. <?=$announcement?>
  126. </u></a>
  127. </td>
  128. <td width="56%" align="left">
  129. <? if ($userinfo['userlevel']==1) { ?>
  130. <u><a href="<?=$url?>?action=delete&uid=<?=$id?>" title="Delete ID# <?=$id?>" onClick="return confirm('You cannot undo this operation!\nDo you wish to delete this record?')" ><u><font color="#FF0000">Delete</font></u></a></u>
  131. <? } ?>
  132. </td>
  133. </tr>
  134. <?
  135. } while ($row = mysql_fetch_array($result));
  136. } else {
  137. ?>
  138. <tr>
  139. <td colspan="3">
  140. <font color="#0000FF">No record is available. </font>
  141. </td>
  142. </tr>
  143. <? } ?>
  144. </table>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td colspan="2" align="center">
  149. <table width="100%" border="1" cellpadding="1" cellspacing="0" class="default">
  150. <tr>
  151. <td align="center" valign="middle" bgcolor="#CCCCCC">
  152. <input type="button" name="add" value="Add Item" onclick="location='<?=$url?>?action=formadd&uid=0'" />
  153. <input type="button" name="listall" value="List All" onclick="location='<?=$url?>'" />
  154. </td>
  155. </tr>
  156. </table>
  157. </td>
  158. </tr>
  159. </table>
  160. </td>
  161. </tr>
  162. <?
  163. }
  164. function fform() {
  165. global $userinfo,$table,$uid,$url,$ptr,$id,$announcement,$link;
  166. if ($uid != 0) {
  167. $sql = "select * from $table where id=$uid";
  168. $result = mysql_query($sql);
  169. $row = mysql_fetch_array($result);
  170. $id = $row['id'];
  171. $announcement = $row['announcement'];
  172. $action = "saveedit";
  173. $label = "UPDATE RECORD";
  174. } else {
  175. $action = "saveadd";
  176. $label = "ADD RECORD";
  177. }
  178. ?>
  179. <tr>
  180. <td align="center" valign="top">
  181. <table width="80%" cellpadding="5" cellspacing="2" class="default">
  182. <tr>
  183. <td colspan="2" align="center">
  184. <table width="70%" border="1" cellpadding="3" cellspacing="0" class="default">
  185. <tr>
  186. <td align="center" valign="middle">
  187. <table width="100%" cellpadding="4" cellspacing="0" class="default">
  188. <form name="frm" method="post" action="<?=$url?>" onSubmit="return checkrequired(this)">
  189. <tr align="center" bgcolor="#CCCCCC">
  190. <td height="30" colspan="2" bgcolor="#CCCCCC">
  191. <b><font size="2">
  192. <?=$label?>
  193. </font></b>
  194. </td>
  195. </tr>
  196. <tr>
  197. <td width="29%" align="right">
  198. <b>Announcement</b>
  199. </td>
  200. <td width="71%">
  201. <input name="_announcement" type="text" id="_announcement" value="<?=$announcement?>" size="30">
  202. </td>
  203. </tr>
  204. <tr align="center">
  205. <td colspan="2" bgcolor="#CCCCCC">
  206. <? if ($userinfo['userlevel']==1 || $userinfo['userlevel']==2) { ?>
  207. <input type="submit" name="Submit" value="Submit">
  208. <? } ?>
  209. <input type="button" name="Back" value="< Back" onclick="location=''">
  210. <input type="hidden" name="action" value="<?=$action?>">
  211. <input type="hidden" name="id" value="<?=$id?>">
  212. </td>
  213. </tr>
  214. </form>
  215. </table>
  216. </td>
  217. </tr>
  218. </table>
  219. </td>
  220. </tr>
  221. </table>
  222. </td>
  223. </tr>
  224. <?
  225. }
  226. function fsave() {
  227. global $action,$table,$ptr;
  228. $id = initobj("id");
  229. $announcement = initobj("_announcement");
  230. $link = initobj("_link");
  231. if ($action=="saveadd") {
  232. $row = fetcharray("select * from $table where announcement='$announcement'");
  233. if (!is_array($row)) {
  234. $sql = "insert into announcements (announcement) values ";
  235. $sql.= "('$announcement')";
  236. mysql_query($sql);
  237. }
  238. } elseif ($action=="saveedit") {
  239. $sql = "update announcements set announcement='$announcement' ";
  240. $sql.= "where id=$id";
  241. mysql_query($sql);
  242. }
  243. flist();
  244. }
  245. function fdelete() {
  246. global $table,$uid;
  247. mysql_query("delete from $table where id=$uid");
  248. flist();
  249. }
  250. switch ($action)
  251. {
  252. case "formadd":
  253. fform();
  254. break;
  255. case "formedit":
  256. fform();
  257. break;
  258. case "saveadd":
  259. fsave();
  260. break;
  261. case "saveedit":
  262. fsave();
  263. break;
  264. case "delete":
  265. fdelete();
  266. break;
  267. default:
  268. flist();
  269. break;
  270. }
  271. ?>
  272. </table>
  273. <? ffooter() ?>

comments powered by Disqus