-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_student.php
180 lines (135 loc) · 4.33 KB
/
table_student.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
session_start();
require_once 'conn.php';
if ($_SESSION['Loggedin'] == true && $_SESSION['type'] == 'admin') {
$query = "SELECT * FROM users_admin WHERE email = '". $_SESSION['email'] ."'";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_array($result);
}else {
header('location:index.php');
}
?>
<?php
if (isset($_GET["pagina"])) {
if($_GET["pagina"]==1){
header("location: table_student.php");
}else {
$pagina = $_GET["pagina"];
}
}else {
$pagina = 1;
}
$_SESSION["pagina"] = $pagina;
?>
<?php include 'includes/header.php'; ?>
<script type="text/javascript">
function ConfirmDelete ()
{
var respuesta = confirm("¿Estas seguro que desea Eliminar al usuario?");
if (respuesta == true){
return true;
}else {
return false;
}
}
</script>
<title>Tabla Estudiantes</title>
<link rel="stylesheet" href="css/verstudent.css">
<link rel="stylesheet" href="css/sidebarstyle3.css">
<?php include 'sidebar.php'; ?>
<body background="img/fondostudent3.png">
<br>
<img src="img/tudent2.svg" align="right" name="fon" class="fon" >
<h1>Estudiantes</h1>
<div style="overflow-x:auto;" class="tabla">
<table border="1">
<thead>
<th>Id</th>
<th>Nombre</th>
<th>Apellido</th>
<th>Curso</th>
<th>Email</th>
<!--<th>Contraseña</th>-->
<th colspan="2">Acciones</th>
</thead>
<tbody>
<?php
$tamagno_pagina = 5;
$empezar_desde = ($pagina - 1)* $tamagno_pagina;
$query_all = "SELECT * FROM users_student";
$result_all = mysqli_query($conn, $query_all);
$num_filas= mysqli_num_rows($result_all);
$query2 = "SELECT * FROM users_student LIMIT $empezar_desde, $tamagno_pagina";
$result2 = mysqli_query($conn, $query2);
$total_paginas= ceil($num_filas/$tamagno_pagina);
if ($total_paginas == 0) {
echo "<br><br>";
}else{
echo "<br><br>";
echo "Numeros de registros de la consulta: ".$num_filas."<br>";
echo "Mostrando la pagina ".$pagina." de " .$total_paginas. "<br>" ;
}
$numero = 1;
while ($row2 = mysqli_fetch_array($result2)) { ?>
<tr>
<td> <?php echo $row2['id'] ?> </td>
<td> <?php echo $row2['nombre'] ?> </td>
<td> <?php echo $row2['apellido'] ?> </td>
<td> <?php echo $row2['seccion'] ?> </td>
<td> <?php echo $row2['email'] ?> </td>
<!--<td> <?php //echo $row2['password'] ?></td>-->
<td>
<a href="modificar_student.php?id=<?php echo $row2['id']?>"><button class="edi">Editar</button> </a>
</td>
<td>
<a href="Eliminar_student.php?id=<?php echo $row2['id']?>"><button class="eli" onclick="return ConfirmDelete()">Eliminar</button> </a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="pagination">
<?php
$i=1;
if ($pagina == 1 || $total_paginas == 0) {
echo "<a class='null'> << </a>";
echo "<a class='null'> < </a>";
}else {
echo "<a href='?pagina=". $i . "' class='flecha'> << </a>";
echo "<a href='?pagina=". ($pagina - 1) . "' class='flecha'> < </a>";
}
for($i=1;$i<=$total_paginas; $i++){
if($pagina == 1){
$limax = $pagina + 4;
}elseif ($pagina == 2) {
$limax = $pagina + 3;
}else {
$limax = $pagina + 2;
}
if ($pagina == $total_paginas) {
$limin = $pagina - 4;
}elseif ($pagina == ($total_paginas - 1) ) {
$limin = $pagina - 3;
}else {
$limin = $pagina - 2;
}
if ($i <= $limax) {
if ($i >= $limin) {
if ($i == $pagina) {
echo "<a href='?pagina=". $i . "' class='active'>". $i . "</a> ";
}else {
echo "<a href='?pagina=". $i . "'>". $i . "</a> ";
}
}
}
}
if ($pagina == $total_paginas || $total_paginas == 0) {
echo "<a class='null'> > </a>";
echo "<a class='null'> >> </a> ";
}else {
echo "<a href='?pagina=". ($pagina + 1) . "' class='flecha'> > </a>";
echo "<a href='?pagina=". $total_paginas . "' class='flecha'> >> </a> ";
}
?>
</div>
<?php include 'includes/footer.php'; ?>