groups.php 1.9 KB

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