PageRenderTime 32ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/main.php

https://bitbucket.org/ihoney/project_honey
PHP | 162 lines | 127 code | 35 blank | 0 comment | 16 complexity | 7b3721827c0c4b2058557beb631d822f MD5 | raw file
  1. <?php
  2. include('template/head.php');
  3. if ($_POST['submit-signup']) {
  4. $sql = "INSERT INTO `db_tour`.`user` (
  5. `u_id` ,
  6. `u_type_id` ,
  7. `u_username` ,
  8. `u_pass` ,
  9. `u_name` ,
  10. `u_email` ,
  11. `u_birthday` ,
  12. `u_address` ,
  13. `u_tel`
  14. )
  15. VALUES (
  16. '', '2', '" . $_POST['u_username'] . "', '" . $_POST['u_pass'] . "', '" . $_POST['u_name'] . "', '" . $_POST['u_email'] . "', '" . $_POST['u_birthday'] . "', '" . $_POST['u_address'] . "', '" . $_POST['u_tel'] . "'
  17. );
  18. ";
  19. $rs = mysql_query($sql);
  20. ?>
  21. <script type="text/javascript">
  22. alert('เพิ่มข้อมูลสำเร็จ');
  23. window.location.href='main.php';
  24. exit();
  25. </script>
  26. <?php
  27. }
  28. $sql = "select * from user,student where user.user_id = student.user_id";
  29. $rs = mysql_query($sql);
  30. $Num_Rows = mysql_num_rows($rs);
  31. $i = 1;
  32. $Per_Page = 10; // Per Page
  33. $Page = $_GET["Page"];
  34. if (!$_GET["Page"]) {
  35. $Page = 1;
  36. }
  37. $Prev_Page = $Page - 1;
  38. $Next_Page = $Page + 1;
  39. $Page_Start = (($Per_Page * $Page) - $Per_Page);
  40. if ($Num_Rows <= $Per_Page) {
  41. $Num_Pages = 1;
  42. } else if (($Num_Rows % $Per_Page) == 0) {
  43. $Num_Pages = ($Num_Rows / $Per_Page);
  44. } else {
  45. $Num_Pages = ($Num_Rows / $Per_Page) + 1;
  46. $Num_Pages = (int) $Num_Pages;
  47. }
  48. $sql .=" order by user.user_id ASC LIMIT $Page_Start , $Per_Page";
  49. $objQuery = mysql_query($sql);
  50. ?>
  51. <script>
  52. $(document).ready(function(){
  53. $('#form-subit').validate();
  54. $( "#date" ).datepicker({dateFormat: "dd/mm/yy"});
  55. });
  56. </script>
  57. <?php
  58. include('template/header.php');
  59. ?>
  60. <div class="main-content">
  61. <div class="user-tool">
  62. <div class="tab-link">
  63. <ui >
  64. <li class="active" ><a href="main.php">อมลนกเรยน</a></li>
  65. <li ><a href="teacher.php">อมลอาจารย</a></li>
  66. <li ><a href="company.php">อมลหนวยงาน</a></li>
  67. </ui>
  68. </div>
  69. <div class="well" id="home">
  70. <table class="table table-bordered">
  71. <tr>
  72. <th>ลำด</th>
  73. <th>รหสนกศกษา</th>
  74. <th>-สก</th>
  75. <th>อผใช</th>
  76. <th>เมล</th>
  77. <th>โทรศพท</th>
  78. <th></th>
  79. </tr>
  80. <?php
  81. if ($Page > 1) {
  82. $i = ($Per_Page * ($Page - 1)) + 1;
  83. }
  84. while ($row = mysql_fetch_array($objQuery)) {
  85. ?>
  86. <tr>
  87. <td><?php echo $i; ?></td>
  88. <td><?php echo $row['std_id']; ?></td>
  89. <td><?php echo $row['name']; ?></td>
  90. <td><?php echo $row['username']; ?></td>
  91. <td><?php echo $row['email']; ?></td>
  92. <td><?php echo $row['phone']; ?></td>
  93. <td >
  94. <a href="main_manage?user_id=<?= $row['user_id'] ; ?>"><i class="icon-pencil"></i></a>
  95. <a href="#myModal" role="button" data-toggle="modal"><i class="icon-remove"></i></a>
  96. </td>
  97. </tr>
  98. <?php
  99. $i++;
  100. }
  101. ?>
  102. </table>
  103. </div>
  104. <div class="pagination">
  105. <ul>
  106. <?php
  107. if ($Prev_Page) {
  108. echo " <li><a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>Prev</a> </li>";
  109. }
  110. for ($i = 1; $i <= $Num_Pages; $i++) {
  111. if ($i != $Page) {
  112. echo "<li> <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a></li> ";
  113. } else {
  114. echo " <li><a href='#'>$i</a></li>";
  115. }
  116. }
  117. if ($Page != $Num_Pages) {
  118. echo " <li><a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next</a> </li>";
  119. }
  120. ?>
  121. </ul>
  122. </div>
  123. <div style="width: 100px;margin: 0 auto;" >
  124. <a href="main_manage.php" class="btn btn-primary">เพมนกเรยน</a>
  125. </div>
  126. </div>
  127. </div>