01.
$u
= 1;
02.
03.
$query_AllNisit
=
"SELECT student_id,name,surname FROM student "
;
04.
$AllNisit
= mysql_query(
$query_AllNisit
,
$connproject
)
or
die
(mysql_error());
05.
$totalRows_AllNisit
= mysql_num_rows(
$AllNisit
);
06.
$Num_Rows
= mysql_num_rows(
$AllNisit
);
07.
08.
09.
$Per_Page
= 2;
10.
11.
$Page
=
$_GET
[
"Page"
];
12.
if
(!
$_GET
[
"Page"
])
13.
{
14.
$Page
=1;
15.
16.
}
17.
18.
19.
20.
$Prev_Page
=
$Page
-1;
21.
$Next_Page
=
$Page
+1;
22.
23.
$Page_Start
= ((
$Per_Page
*
$Page
)-
$Per_Page
);
24.
if
(
$Num_Rows
<=
$Per_Page
)
25.
{
26.
$Num_Pages
=1;
27.
}
28.
else
if
((
$Num_Rows
%
$Per_Page
)==0)
29.
{
30.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
) ;
31.
}
32.
else
33.
{
34.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
)+1;
35.
$Num_Pages
= (int)
$Num_Pages
;
36.
}
37.
38.
$query_AllNisit
.=
" ORDER BY student_id DESC LIMIT $Page_Start , $Per_Page"
;
39.
$AllNisit
= mysql_query(
$query_AllNisit
);
40.
41.
42.
43.
if
(
$totalRows_AllNisit
> 0) {
44.
<table width=
"100%"
border=
"1"
cellspacing=
"0"
cellpadding=
"0"
>
45.
<tr>
46.
<td width=
"83"
><div align=
"center"
class
=
"style6"
>ลำดับที่</div></td>
47.
<td width=
"173"
><div align=
"center"
class
=
"style6"
>รหัสนิสิต</div></td>
48.
<td width=
"217"
><div align=
"center"
class
=
"style6"
>ชื่อ</div></td>
49.
<td width=
"201"
><div align=
"center"
class
=
"style6"
>นามสกุล</div></td>
50.
</tr>
51.
52.
<?php
while
(
$row_AllNisit
= mysql_fetch_assoc(
$AllNisit
))
53.
{ ?>
54.
<tr>
55.
<td><div align=
"center"
><?php
echo
$u
++.
"."
; ?></div></td>
56.
<td><div align=
"center"
><?php
echo
$row_AllNisit
[
'student_id'
]; ?></div></td>
57.
<td ><?php
echo
$row_AllNisit
[
'name'
]; ?></td>
58.
<td ><?php
echo
$row_AllNisit
[
'surname'
]; ?></td>
59.
</tr>
60.
<?php } ?>
61.
</table>
62.
63.
64.
Total <?php
echo
$Num_Rows
;?> Record : <?php
echo
$Num_Pages
;?> Page :
65.
<?
66.
if
(
$Prev_Page
)
67.
{
68.
echo
" <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><< Back</a> "
;
69.
}
70.
71.
for
(
$i
=1;
$i
<=
$Num_Pages
;
$i
++){
72.
if
(
$i
!=
$Page
)
73.
{
74.
echo
"[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]"
;
75.
}
76.
else
77.
{
78.
echo
"<b> $i </b>"
;
79.
}
80.
}
81.
if
(
$Page
!=
$Num_Pages
)
82.
{
83.
echo
" <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next>></a> "
;
84.
}
85.
86.
87.
88.
89.
90.
}
91.