Issues (4542)

config/class_paging.php (3 issues)

1
<?php
2
3
class paging
4
{
5
    // Fungsi untuk mencek halaman dan posisi data
6
7
    public function cariPosisi($batas)
8
    {
9
        if (empty($_GET[halaman])) {
0 ignored issues
show
The constant halaman was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
10
            $posisi = 0;
11
12
            $_GET[halaman] = 1;
13
        } else {
14
            $posisi = ($_GET[halaman] - 1) * $batas;
15
        }
16
17
        return $posisi;
18
    }
19
20
    // Fungsi untuk menghitung total halaman
21
22
    public function jumlahHalaman($jmldata, $batas)
23
    {
24
        $jmlhalaman = ceil($jmldata / $batas);
25
26
        return $jmlhalaman;
27
    }
28
29
    // Fungsi untuk link halaman 1,2,3 ... Next, Prev, First, Last
30
31
    public function navHalaman($halaman_aktif, $jmlhalaman)
32
    {
33
        $link_halaman = '';
34
35
        if (($halaman_aktif - 1) > 0) {
36
            $previous = $halaman_aktif - 1;
37
38
            $link_halaman .= "<a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$previous title=Previous><<</a>&nbsp;";
39
        }
40
41
        // Link halaman 1,2,3, ...
42
43
        //for ($i=1; $i<=$jmlhalaman; $i++)
44
//
45
        //{
46
//
47
        //if ($i == $halaman_aktif)
48
//
49
        //{
50
//
51
        //$link_halaman .= "<b class='currenthalaman'>$i</b>";
52
//
53
        //}
54
//
55
        //else
56
//
57
        //{
58
//
59
        //$link_halaman .= "<a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$i>$i</a>";
60
//
61
        //}
62
//
63
        //$link_halaman .= " ";
64
//
65
        //}
66
67
        ///
68
69
        $angka = ($halaman > 3 ? ' ... ' : ' ');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $halaman does not exist. Did you maybe mean $link_halaman?
Loading history...
70
        for ($i = $halaman - 2; $i < $halaman; $i++) {
71
            if ($i < 1) {
72
                continue;
73
            }
74
            $angka .= "<a href=$_SERVER[PHP_SELF]?halaman=$i>$i</A> ";
75
        }
76
77
        $angka .= " <b>$halaman</b> ";
78
        for ($i = $halaman + 1; $i < ($halaman + 3); $i++) {
79
            if ($i > $jmlhalaman) {
80
                break;
81
            }
82
            $angka .= "<a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$i>$i</A> ";
83
        }
84
85
        $angka .= ($halaman + 2 < $jmlhalaman ? " ...  
86
          <a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$jmlhalaman>$jmlhalaman</A> " : ' ');
87
88
        echo "$angka";
89
90
        // Link Next dan Last
91
92
        if ($halaman_aktif < $jmlhalaman) {
93
            $next = $halaman_aktif + 1;
94
95
            $link_halaman .= " <a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$next title=Next>>></a> ";
96
        }
97
98
        return $link_halaman;
99
    }
100
}
101
102
?>
103
104
105
106
107
108
<?php /*?><?php
109
110
class Paging
111
112
{
113
114
// Fungsi untuk mencek halaman dan posisi data
115
116
function cariPosisi($batas)
117
118
{
119
120
if(empty($_GET[halaman])){
121
122
    $posisi=0;
123
124
    $_GET[halaman]=1;
125
126
}
127
128
else{
129
130
    $posisi = ($_GET[halaman]-1) * $batas;
131
132
}
133
134
return $posisi;
135
136
}
137
138
139
140
// Fungsi untuk menghitung total halaman
141
142
function jumlahHalaman($jmldata, $batas)
143
144
{
145
146
$jmlhalaman = ceil($jmldata/$batas);
147
148
return $jmlhalaman;
149
150
}
151
152
153
154
// Fungsi untuk link halaman 1,2,3 ... Next, Prev, First, Last
155
156
function navHalaman($halaman_aktif, $jmlhalaman)
157
158
{
159
160
$link_halaman = "";
161
162
163
164
165
166
if (($halaman_aktif-1) > 0)
167
168
{
169
170
$previous = $halaman_aktif-1;
171
172
$link_halaman .= "<a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$previous&act=cari_$_GET[module] title=Previous><<</a>&nbsp;";
173
174
}
175
176
177
178
// Link halaman 1,2,3, ...
179
180
for ($i=1; $i<=$jmlhalaman; $i++)
181
182
{
183
184
if ($i == $halaman_aktif)
185
186
{
187
188
$link_halaman .= "<b class='currenthalaman'>$i</b>";
189
190
}
191
192
else
193
194
{
195
196
$link_halaman .= "<a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$i&act=cari_$_GET[module]>$i</a>";
197
198
}
199
200
$link_halaman .= " ";
201
202
}
203
204
205
206
// Link Next dan Last
207
208
if ($halaman_aktif < $jmlhalaman)
209
210
{
211
212
$next=$halaman_aktif+1;
213
214
$link_halaman .= " <a href=$_SERVER[PHP_SELF]?module=$_GET[module]&halaman=$next&act=cari_$_GET[module]	 title=Next>>></a> ";
215
216
}
217
218
219
220
return $link_halaman;
221
222
}
223
224
}
225
226
?>
227
228
<?php */?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...