paginanummering

Gesponsorde koppelingen

PHP script bestanden

  1. paginanummering

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Paginanummering</title>
<style type="text/css">
body{font-family:Arial, Helvetica, sans-serif; font-size:12px;}
h2{clear:both; border:0; margin:0; padding-top:30px; font-size:13px;}
p{border:0; margin:0; padding:0; padding-bottom:20px;}
</style>
<style type="text/css">
/* -------------------------------------------- */
/*         Pagination: Digg Style                    */
/* -------------------------------------------- */
    ul{border:0; margin:0; padding:0;}

    #pagination-digg li{
        border:0; margin:0; padding:0;
        font-size:11px;
        list-style:none;
    }
    #pagination-digg a{
        border:solid 1px #9aafe5;
        margin-right:2px;
    }
    #pagination-digg .previous-off,
    #pagination-digg .next-off {
        border:solid 1px #DEDEDE;
        color:#888888;
        display:block;
        float:left;
        font-weight:bold;
        margin-right:2px;
        padding:3px 4px;
    }
    #pagination-digg .next a,
    #pagination-digg .previous a {
     font-weight:bold;
    }    
    #pagination-digg .active{
        background:#2e6ab1;
        color:#FFFFFF;
        font-weight:bold;
        display:block;
        float:left;
        padding:4px 6px;
    }
    #pagination-digg a:link,
    #pagination-digg a:visited {
        color:#0e509e;
        display:block;
        float:left;
        padding:3px 6px;
        text-decoration:none;
    }
    #pagination-digg a:hover{
        border:solid 1px #0e509e;
    }
</style>
</head>

<body>
<?php
////////////////////////////////////////////
/// Edit by: Daniël                      ///
/// xfire: tjonger                       ///
////////////////////////////////////////////

$host = "";  // De host van uw server. 99 van de 100 keer is dit localhost.
$user = "";  // De gebruiker van de database. Bij het aanmaken van de database heeft u dit moeten opgeven.
$pass = "";  // Het wachtwoord van de database. Bij het aanmaken van de database heeft u dit moeten opgeven.
$db = "";  // De database. Bij het aanmaken van de database heeft u dit moeten opgeven.
$table = "l"; // naam van je mysql table
$max = 10; // aantal items per pagina
///////////////////////////////////////////////////
// Niks aanpassen, als je niet weet wat je doet. //
///////////////////////////////////////////////////

$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
$db = mysql_select_db($db);

// find out how many rows are in the table
$sql = "SELECT COUNT(*) FROM $table";
$result = mysql_query($sql, $conn);
$r = mysql_fetch_row($result);
$numrows = $r[0];

// find out total pages
$totalpages = ceil($numrows / $max);

// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
   // cast var as int
   $currentpage = (int) $_GET['currentpage'];
}
else {
   // default page num
   $currentpage = 1;
}
// end if

// if current page is greater than total pages...

if ($currentpage > $totalpages) {
   // set current page to last page
   $currentpage = $totalpages;
}
// end if
// if current page is less than first page...

if ($currentpage < 1) {
   // set current page to first page
   $currentpage = 1;
}
// end if

// the offset of the list, based on current page

$offset = ($currentpage - 1) * $rowsperpage;

/******  build the pagination links ******/
// range of num links to show

$range = 3;

echo "<ul id=\"pagination-digg\">";
// if not on page 1, don't show back links
if ($currentpage > 1) {
   // get previous page num
   echo " <li class=\"next\"><a href='{$_SERVER['PHP_SELF']}?currentpage=1'>«« Eerste pagina</a><li> ";
   $prevpage = $currentpage - 1;
   // show < link to go back to 1 page
   echo " <li class=\"next\"><a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>« Vorige</a><li> ";
}
// end if

// loop to show links to range of pages around current page

for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
   // if it's a valid page number...
   if (($x > 0) && ($x <= $totalpages)) {
      // if we're on current page...
      if ($x == $currentpage) {
         // 'highlight' it but don't make a link
         echo " <li class=\"active\">$x</li> ";
      // if not current page...
      } else {
         // make it a link
         echo " <li><a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a><li> ";
      }
// end else
   } // end if
} // end for
                
// if not on last page, show forward and last page links        

if ($currentpage != $totalpages) {
   // get next page
   $nextpage = $currentpage + 1;
    // echo forward link for next page
   echo " <li class=\"next\"><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>Volgende »</a></li> ";
  
   echo " <li class=\"next\"><a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>Laatste pagina »»</a></li> ";
}
// end if
/****** end build pagination links ******/

echo "</ul>";
?>

</body>
</html>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.