groups.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
  4. if (isset($_POST["create"])) {
  5. $fname = $_POST["newgroup"];
  6. if ($fname) {
  7. $new['group_name'] = $fname;
  8. $new_id=insert_record($db_link, "Group_list", $new);
  9. header("location: editgroup.php?id=$new_id");
  10. exit;
  11. }
  12. header("Location: " . $_SERVER["REQUEST_URI"]);
  13. exit;
  14. }
  15. if (isset($_POST["remove"])) {
  16. $fgid = $_POST["fid"];
  17. foreach ($fgid as $key => $val) {
  18. if (!empty($val)) { delete_record($db_link, "Group_list", "id=" . $val * 1); }
  19. }
  20. header("Location: " . $_SERVER["REQUEST_URI"]);
  21. exit;
  22. }
  23. unset($_POST);
  24. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  25. print_filters_submenu($page_url);
  26. ?>
  27. <div id="cont">
  28. <br> <b>Список групп</b> <br>
  29. <form name="def" action="groups.php" method="post">
  30. <table class="data">
  31. <tr align="center">
  32. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  33. <td><b>Id</b></td>
  34. <td width=200><b>Название</b></td>
  35. </tr>
  36. <?php
  37. $users = mysqli_query($db_link, "select * from Group_list order by id");
  38. while (list ($id, $grpname) = mysqli_fetch_array($users)) {
  39. print "<tr align=center>\n";
  40. print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=$id></td>\n";
  41. print "<td class=\"data\" ><input type=\"hidden\" name=\"id\" value=$id>$id</td>\n";
  42. print "<td class=\"data\"><a href=editgroup.php?id=$id>" . $grpname . "</a></td>\n";
  43. }
  44. ?>
  45. </table>
  46. <table class="data">
  47. <tr align=left>
  48. <td>Название <input type=text name=newgroup value="Unknown"></td>
  49. <td><input type="submit" name="create" value="Добавить"></td>
  50. <td align="right"><input type="submit" onclick="return confirm('Удалить?')" name="remove" value="Удалить"></td>
  51. </tr>
  52. </table>
  53. </form>
  54. <?php
  55. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  56. ?>