PHP Navigatie vraag

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

A Jansen

A Jansen

14/03/2009 09:43:00
Quote Anchor link
Hallo,

Ik heb een vraag hoe kan ik deze script toevoegen aan mijn website.

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
<?php
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         = 1000; // 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>

</head>
<body>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
            echo $output;
        ?>

</body>
</html>

Dit is wat ik nu heb de knoppen Eerst Vorige Volgende Laatste, wou ik graag vervangen door cijfers (zie voorbeeld hier boven)

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php require_once('Connections/Proberen.php'); ?>

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
<?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);
?>

<!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>
<table border="1" align="center">
<tr>
<td>Camping</td>
<td>Type</td>
<td>Plaats</td>
<td>Website (Ja/Nee)</td>
</tr>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php do { ?>

<tr>
<td><a href="Camping.php?recordID=
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $row_Flevoland['Nr']; ?>
">
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $row_Flevoland['Camping']; ?>
&nbsp; </a> </td>
<td>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $row_Flevoland['Type']; ?>
&nbsp; </td>
<td>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $row_Flevoland['Plaats']; ?>
&nbsp; </td>
<td>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $row_Flevoland['Website (Ja/Nee)']; ?>
&nbsp; </td>
</tr>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php } while ($row_Flevoland = mysql_fetch_assoc($Flevoland)); ?>

</table>
<br />
<table border="0">
<tr>
<td>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php if ($pageNum_Flevoland > 0) { // Show if not first page ?>

<a href="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php printf("%s?pageNum_Flevoland=%d%s", $currentPage, 0, $queryString_Flevoland); ?>
">Eerst</a>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php } // Show if not first page ?>

</td>
<td>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php if ($pageNum_Flevoland > 0) { // Show if not first page ?>

<a href="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php printf("%s?pageNum_Flevoland=%d%s", $currentPage, max(0, $pageNum_Flevoland - 1), $queryString_Flevoland); ?>
">Vorige</a>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php } // Show if not first page ?>

</td>
<td>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php if ($pageNum_Flevoland < $totalPages_Flevoland) { // Show if not last page ?>

<a href="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php printf("%s?pageNum_Flevoland=%d%s", $currentPage, min($totalPages_Flevoland, $pageNum_Flevoland + 1), $queryString_Flevoland); ?>
">Volgende</a>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php } // Show if not last page ?>

</td>
<td>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php if ($pageNum_Flevoland < $totalPages_Flevoland) { // Show if not last page ?>

<a href="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php printf("%s?pageNum_Flevoland=%d%s", $currentPage, $totalPages_Flevoland, $queryString_Flevoland); ?>
">Laatste</a>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php } // Show if not last page ?>

</td>
</tr>
</table>
Records
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo ($startRow_Flevoland + 1) ?>
tot
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo min($startRow_Flevoland + $maxRows_Flevoland, $totalRows_Flevoland) ?>
van
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $totalRows_Flevoland ?>

</body>
</html>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
mysql_free_result($Flevoland);
?>


Groetjes A Jansen
 
PHP hulp

PHP hulp

14/05/2024 09:10:42
 
A Jansen

A Jansen

14/03/2009 09:44:00
Quote Anchor link
Bedankt
Gewijzigd op 01/01/1970 01:00:00 door A Jansen
 



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.