Pagina nummers werken niet meer

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

A Jansen

A Jansen

15/03/2009 14:24:00
Quote Anchor link
Probleem mijn pagina nummering werkt niet meer.

Het doet niets als ik op de cijfers 1 2 3 klik.
Heb in mijn database 59 records staan ik wil per keer 25 weer geven, als ik nu op een pagina nummer (Bijv. 2 of 3) klik blijf ik alleen de eerste 25 zien. Je moet dan 26 tot 50 zien.

Ik hoop dat iemand mij hier mee kan helpen.

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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php require_once('Connections/Proberen.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function
GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{

  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case
"text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case
"long":
    case
"int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case
"double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case
"date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case
"defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }

  return $theValue;
}
}


$currentPage = $_SERVER["PHP_SELF"];

$maxRows_Flevoland = 25;
$pageNum_Flevoland = 0;
if (isset($_GET['pageNum_Flevoland'])) {
  $pageNum_Flevoland = $_GET['pageNum_Flevoland'];
}

$startRow_Flevoland = $pageNum_Flevoland * $maxRows_Flevoland;

mysql_select_db($database_Proberen, $Proberen);
$query_Flevoland = "SELECT * FROM flevoland ORDER BY Plaats ASC, flevoland.Camping";
$query_limit_Flevoland = sprintf("%s LIMIT %d, %d", $query_Flevoland, $startRow_Flevoland, $maxRows_Flevoland);
$Flevoland = mysql_query($query_limit_Flevoland, $Proberen) or die(mysql_error());
$row_Flevoland = mysql_fetch_assoc($Flevoland);

if (isset($_GET['totalRows_Flevoland'])) {
  $totalRows_Flevoland = $_GET['totalRows_Flevoland'];
}
else {
  $all_Flevoland = mysql_query($query_Flevoland);
  $totalRows_Flevoland = mysql_num_rows($all_Flevoland);
}

$totalPages_Flevoland = ceil($totalRows_Flevoland/$maxRows_Flevoland)-1;

$queryString_Flevoland = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Flevoland") == false &&
        stristr($param, "totalRows_Flevoland") == false) {
      array_push($newParams, $param);
    }
  }

  if (count($newParams) != 0) {
    $queryString_Flevoland = "&" . htmlentities(implode("&", $newParams));
  }
}

$queryString_Flevoland = sprintf("&totalRows_Flevoland=%d%s", $totalRows_Flevoland, $queryString_Flevoland);

function
navigatie($currentpage,$totalpages,$url)
{

    $output         = '';
    $output_num        = '';

    // both = 4 of meer
    if (($currentpage - 4) > 0 && ($currentpage + 4) < $totalpages) {
        for($a = ($currentpage-4);$a <= ($currentpage+4);$a++) {
            if ($a == $currentpage) {
                $output_num     .= ' <b>[' . $a .']</b> ';
            }
else {
                $output_num     .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
            }
        }

        if (($currentpage - 4) == 1) {
            $first     = false;
        }
else {
            $first     = true;
        }

        if (($currentpage + 4) == $totalpages) {
            $last     = false;
        }
else {
            $last     = true;
        }

        
    // left = 4 of meer
    } elseif (($currentpage - 4) > 0) {
        $math         = $totalpages - $currentpage;
        $start_temp    = 9 - $math;
        $start         = $currentpage - $start_temp;
        if ($start < 1) {
            $start      = 1;
        }

        for($a = $start;$a <= $totalpages;$a++) {
            if ($a == $currentpage) {
                $output_num     .= ' <b>[' . $a .']</b> ';
            }
else {
                $output_num     .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
            }
        }

        $last     = false;
        $first     = true;
    // right = 4 of meer
    } elseif (($currentpage + 4) < $totalpages) {
        if ($totalpages > 9) {
            $loop = 9;
        }
else {
            $loop = $totalpages;
        }

        for($a = 1;$a <= $loop;$a++) {
            if ($a == $currentpage) {
                $output_num     .= ' <b>[' . $a .']</b> ';
            }
else {
                $output_num     .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
            }
        }

        $last     = true;
        $first     = false;
    // none = 4 of meer
    } else {
        for($a = 1;$a <= $totalpages;$a++) {
            if ($a == $currentpage) {
                $output_num     .= ' <b>[' . $a .']</b> ';
            }
else {
                $output_num     .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
            }
        }

        $last     = false;
        $first     = false;
    }

    if ($first == true) {
        $output     .= ' <b><a href="' . $url . '1">[eerste]</a></b> ';
    }

    if ($currentpage != 1) {
        $output     .= ' <b><a href="' . $url . ($currentpage-1) .' ">[vorige]</a></b> ';
    }

    $output         .= " &nbsp;&nbsp; " . $output_num . "&nbsp;&nbsp;";
    if ($currentpage != $totalpages) {
        $output      .= ' <b><a href="' . $url . ($currentpage+1) . ' ">[volgende]</a></b> ';
    }

    if ($last == true) {
        $output     .= '<b><a href="' . $url . $totalpages . ' ">[laatste]</a></b> ';
    }

    
        return $output;
}


$itemsperpage         = 25;
$totalrecords         = $totalRows_Flevoland; // dit kan een aantal records zijn uit de database
$totalpages           = ceil($totalrecords/$itemsperpage);
if (!IsSet($_GET['p'])) {
    $currentpage     = 1;
}
else {
    $currentpage     = ceil($_GET['p']);
}

if ($currentpage < 1 || $currentpage > ceil($totalpages)) {
    $output     = 'Helaas, deze pagina bestaat niet.';
}
else {
    $output     = navigatie($currentpage,$totalpages,'?p=');
    $output     .= '<br /><br />Pagina: ' . $currentpage;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<div align="center">
  <table border="1" align="center">
    <tr>
      <td>Camping</td>
      <td>Type</td>
      <td>Plaats</td>
      <td>Website (Ja/Nee)</td>
    </tr>
    <?php do { ?>
      <tr>
        <td><a href="Camping.php?recordID=<?php echo $row_Flevoland['Nr']; ?>"> <?php echo $row_Flevoland['Camping']; ?>&nbsp; </a> </td>
        <td><?php echo $row_Flevoland['Type']; ?>&nbsp; </td>
        <td><?php echo $row_Flevoland['Plaats']; ?>&nbsp; </td>
        <td><?php echo $row_Flevoland['Website (Ja/Nee)']; ?>&nbsp; </td>
      </tr>
      <?php } while ($row_Flevoland = mysql_fetch_assoc($Flevoland)); ?>
  </table>
  <br />
  <?php
            echo $output;
        ?>

</div>
</body>
</html>
<?php
mysql_free_result($Flevoland);
?>
Gewijzigd op 01/01/1970 01:00:00 door A Jansen
 
PHP hulp

PHP hulp

14/05/2024 05:47:35
 
- SanThe -

- SanThe -

15/03/2009 14:30:00
Quote Anchor link
Je post is nu niet echt leesbaar. Pas je post even aan en gebruik en tags om je code heen. Om php code zet je uiteraard dit:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php en ?>
Gebruik je Afbeelding knop om dit te doen.

Verder is het handig om een vraag te stellen en om alléén relevante code te plaatsen en geen compleet script.

SanThe.
 
Jesper Diovo

Jesper Diovo

15/03/2009 15:49:00
Quote Anchor link
1. Doe wat SanThe zegt.
2. Wat zijn je errors?
3. Waar spelen die errors op?
4. Wat doet hij niet meer wat hij wel had moeten doen?

En ga zo nog maar even door. Ben duidelijk in je vraagstelling!
 
A Jansen

A Jansen

16/03/2009 18:17:00
Quote Anchor link
Sorry ik heb het bericht gisteren snel geplaats maar nu weer aangepast.
Ik hoop dat het nu wat duidelijker is.
 



Overzicht Reageren

 
 

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.