/admin/main.php
PHP | 162 lines | 127 code | 35 blank | 0 comment | 16 complexity | 7b3721827c0c4b2058557beb631d822f MD5 | raw file
- <?php
- include('template/head.php');
- if ($_POST['submit-signup']) {
- $sql = "INSERT INTO `db_tour`.`user` (
- `u_id` ,
- `u_type_id` ,
- `u_username` ,
- `u_pass` ,
- `u_name` ,
- `u_email` ,
- `u_birthday` ,
- `u_address` ,
- `u_tel`
- )
- VALUES (
- '', '2', '" . $_POST['u_username'] . "', '" . $_POST['u_pass'] . "', '" . $_POST['u_name'] . "', '" . $_POST['u_email'] . "', '" . $_POST['u_birthday'] . "', '" . $_POST['u_address'] . "', '" . $_POST['u_tel'] . "'
- );
- ";
- $rs = mysql_query($sql);
- ?>
- <script type="text/javascript">
- alert('เพิ่มข้อมูลสำเร็จ');
- window.location.href='main.php';
- exit();
- </script>
- <?php
- }
- $sql = "select * from user,student where user.user_id = student.user_id";
- $rs = mysql_query($sql);
- $Num_Rows = mysql_num_rows($rs);
- $i = 1;
- $Per_Page = 10; // Per Page
- $Page = $_GET["Page"];
- if (!$_GET["Page"]) {
- $Page = 1;
- }
- $Prev_Page = $Page - 1;
- $Next_Page = $Page + 1;
- $Page_Start = (($Per_Page * $Page) - $Per_Page);
- if ($Num_Rows <= $Per_Page) {
- $Num_Pages = 1;
- } else if (($Num_Rows % $Per_Page) == 0) {
- $Num_Pages = ($Num_Rows / $Per_Page);
- } else {
- $Num_Pages = ($Num_Rows / $Per_Page) + 1;
- $Num_Pages = (int) $Num_Pages;
- }
- $sql .=" order by user.user_id ASC LIMIT $Page_Start , $Per_Page";
- $objQuery = mysql_query($sql);
- ?>
- <script>
- $(document).ready(function(){
- $('#form-subit').validate();
- $( "#date" ).datepicker({dateFormat: "dd/mm/yy"});
- });
- </script>
- <?php
- include('template/header.php');
- ?>
- <div class="main-content">
- <div class="user-tool">
- <div class="tab-link">
- <ui >
- <li class="active" ><a href="main.php">ข้อมูลนักเรียน</a></li>
- <li ><a href="teacher.php">ข้อมูลอาจารย์</a></li>
- <li ><a href="company.php">ข้อมูลหน่วยงาน</a></li>
- </ui>
- </div>
- <div class="well" id="home">
- <table class="table table-bordered">
- <tr>
- <th>ลำดับ</th>
- <th>รหัสนึกศึกษา</th>
- <th>ชื่อ-สกุล</th>
- <th>ชื่อผู้ใช้</th>
- <th>อีเมล</th>
- <th>โทรศัพท์</th>
- <th></th>
- </tr>
- <?php
- if ($Page > 1) {
- $i = ($Per_Page * ($Page - 1)) + 1;
- }
- while ($row = mysql_fetch_array($objQuery)) {
- ?>
- <tr>
- <td><?php echo $i; ?></td>
- <td><?php echo $row['std_id']; ?></td>
- <td><?php echo $row['name']; ?></td>
- <td><?php echo $row['username']; ?></td>
- <td><?php echo $row['email']; ?></td>
- <td><?php echo $row['phone']; ?></td>
- <td >
- <a href="main_manage?user_id=<?= $row['user_id'] ; ?>"><i class="icon-pencil"></i></a>
- <a href="#myModal" role="button" data-toggle="modal"><i class="icon-remove"></i></a>
- </td>
- </tr>
- <?php
- $i++;
- }
- ?>
- </table>
- </div>
-
- <div class="pagination">
- <ul>
- <?php
- if ($Prev_Page) {
- echo " <li><a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>Prev</a> </li>";
- }
- for ($i = 1; $i <= $Num_Pages; $i++) {
- if ($i != $Page) {
- echo "<li> <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a></li> ";
- } else {
- echo " <li><a href='#'>$i</a></li>";
- }
- }
- if ($Page != $Num_Pages) {
- echo " <li><a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next</a> </li>";
- }
- ?>
- </ul>
- </div>
- <div style="width: 100px;margin: 0 auto;" >
- <a href="main_manage.php" class="btn btn-primary">เพิ่มนักเรียน</a>
- </div>
- </div>
- </div>