Pagina navigatie.
Ik ben nieuw op dit forum en heb een vraag over pagina navigatie.
Er worden een aantal resultaten uit de database gehaald en het is de bedoeling dat ik maximaal 20 records per pagina te zien krijg. Onder alle records staat dan een linkje met Vorige en Volgende om tussen de pagina's te navigeren.
de pagina navigatie werkt goed alleen onder alle records en de linkjes met vorige en volgende, wordt steeds weer een tabel geprint. Het lijkt wel of deze pagina in een oneindige lus zit.
misschien is er iemand die kan helpen.
hier het script.
Code (php)
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
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
<?php
$Categorie = 'xxxxxx';
mysql_connect ("xxxxxxxx","xxxxxxxx","xxxxxxxx")or die (mysql_error());
mysql_select_db("xxxxxxxx")or die (mysql_error());
$query = mysql_query ("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$Categorie' ORDER BY Opdracht_ID ")or die (mysql_error());
$result = mysql_query("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$Categorie' ORDER BY Opdracht_ID ")or die (mysql_error());
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
//aantal records per pagina
$max = 20;
$start = ($max * $page) - $max;
//hier je gegevens van je mysql ophalen
while($var = mysql_fetch_array(mysql_query("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$Categorie' ORDER BY Opdracht_ID LIMIT " . $start . ", " . $max . ""))) {
echo"<center>";
echo "<table border='1' BORDERCOLOR =#3ADF00>
<tr>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
$xxxxxx = $row['xxxxxx'];
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td><a href = 'xxxxxxxx'>xxxxxxxx</a></td>";
echo "</tr>";
echo "</table>";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//hier aan jou mysql gegevens aanpassen
$rows = mysql_result(mysql_query("SELECT COUNT(Opdracht_ID) FROM opdrachten_gegevens ORDER BY Opdracht_ID"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\">Vorige</a> ";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
} else {
echo "<b>" . $i . "</b>, ";
}
} else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> ";
} else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, ";
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">Volgende</a>";
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
$Categorie = 'xxxxxx';
mysql_connect ("xxxxxxxx","xxxxxxxx","xxxxxxxx")or die (mysql_error());
mysql_select_db("xxxxxxxx")or die (mysql_error());
$query = mysql_query ("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$Categorie' ORDER BY Opdracht_ID ")or die (mysql_error());
$result = mysql_query("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$Categorie' ORDER BY Opdracht_ID ")or die (mysql_error());
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
//aantal records per pagina
$max = 20;
$start = ($max * $page) - $max;
//hier je gegevens van je mysql ophalen
while($var = mysql_fetch_array(mysql_query("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$Categorie' ORDER BY Opdracht_ID LIMIT " . $start . ", " . $max . ""))) {
echo"<center>";
echo "<table border='1' BORDERCOLOR =#3ADF00>
<tr>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
$xxxxxx = $row['xxxxxx'];
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td><a href = 'xxxxxxxx'>xxxxxxxx</a></td>";
echo "</tr>";
echo "</table>";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//hier aan jou mysql gegevens aanpassen
$rows = mysql_result(mysql_query("SELECT COUNT(Opdracht_ID) FROM opdrachten_gegevens ORDER BY Opdracht_ID"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\">Vorige</a> ";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
} else {
echo "<b>" . $i . "</b>, ";
}
} else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> ";
} else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, ";
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">Volgende</a>";
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
Zorg er eerst even voor dat het door het inspringen duidelijk is wat er binnen je while loops valt.
Waar eindigt bv de While-loop die je op tegen 20 start?
En volgens mij eindig je op regel 61 de while-loop die je op regel 38 start. Je sluit hier door heel vaak een table, echter deze open je niet binnen deze while. (Waardoor je veel vaken een table sluit dan opent)
Zodra je je code correct hebt ingespronken, verwacht ik dat je al ziet waar het probleem exact zit
Wat bedoel je precies met inspringen.. Ik ben een beginner op php gebied en heb dit script van internet gehaald en een beetje aangepast.
De while loop die ik op regel 20 start laat ik eindigen op regel 104.
volgens mij staat er nog ergens een klein foutje in het script.
gr
Wouter
Code (php)
Een stuk beter leesbaarder is dit.
Code (php)
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
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
<?php
//variabelen beginnen met een kleine letter
$categorie = 'xxxxxx';
mysql_connect ("xxxxxxxx","xxxxxxxx","xxxxxxxx")or die (mysql_error());
mysql_select_db("xxxxxxxx")or die (mysql_error());
//aantal records per pagina
$max = 20;
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
$start = ($max * $page) - $max;
//query maar 1x nodig.
//Tevens limit toegevoegd
//Liever geen tabelnamen met een hoofdletter
$result = mysql_query(" SELECT
*
FROM
opdrachten_gegevens
WHERE
Categorie = '{$categorie}'
LIMIT
($start},{$max}
ORDER BY
Opdracht_ID ")or die (mysql_error());
//html tag <center> is outdated
echo"<center>";
//Begin nieuwe tabel
echo "<table border='1' BORDERCOLOR =#3ADF00>";
//Maak eerste rij
echo "<tr>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
</tr>";
//hier je gegevens van je mysql ophalen
while($row = mysql_fetch_array($result)) {
echo "<tr>";
//Wat is dit?
$xxxxxx = $row['xxxxxx'];
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td><a href = 'xxxxxxxx'>xxxxxxxx</a></td>";
echo "</tr>";
}
//Afsluiten van tabel buiten de while gehaald
echo "</table>";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//hier aan jou mysql gegevens aanpassen
//Categorie toegevoegd
$rows = mysql_result(mysql_query("SELECT COUNT(Opdracht_ID) FROM opdrachten_gegevens WHERE Categorie = '{$categorie}' ORDER BY Opdracht_ID"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\">Vorige</a> ";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
}
else {
echo "<b>" . $i . "</b>, ";
}
}
else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> ";
}
else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, ";
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">Volgende</a>";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
//variabelen beginnen met een kleine letter
$categorie = 'xxxxxx';
mysql_connect ("xxxxxxxx","xxxxxxxx","xxxxxxxx")or die (mysql_error());
mysql_select_db("xxxxxxxx")or die (mysql_error());
//aantal records per pagina
$max = 20;
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
$start = ($max * $page) - $max;
//query maar 1x nodig.
//Tevens limit toegevoegd
//Liever geen tabelnamen met een hoofdletter
$result = mysql_query(" SELECT
*
FROM
opdrachten_gegevens
WHERE
Categorie = '{$categorie}'
LIMIT
($start},{$max}
ORDER BY
Opdracht_ID ")or die (mysql_error());
//html tag <center> is outdated
echo"<center>";
//Begin nieuwe tabel
echo "<table border='1' BORDERCOLOR =#3ADF00>";
//Maak eerste rij
echo "<tr>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
<th>xxxxxx</th>
</tr>";
//hier je gegevens van je mysql ophalen
while($row = mysql_fetch_array($result)) {
echo "<tr>";
//Wat is dit?
$xxxxxx = $row['xxxxxx'];
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxx'] . "</td>";
echo "<td><a href = 'xxxxxxxx'>xxxxxxxx</a></td>";
echo "</tr>";
}
//Afsluiten van tabel buiten de while gehaald
echo "</table>";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//hier aan jou mysql gegevens aanpassen
//Categorie toegevoegd
$rows = mysql_result(mysql_query("SELECT COUNT(Opdracht_ID) FROM opdrachten_gegevens WHERE Categorie = '{$categorie}' ORDER BY Opdracht_ID"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\">Vorige</a> ";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
}
else {
echo "<b>" . $i . "</b>, ";
}
}
else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> ";
}
else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, ";
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">Volgende</a>";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
Groeten, Wouter
Kijk goed naar het verschil, en zorg dat je altijd netjes werkt. (inspringen etc) Daarmee haal je de helft van je fouten er al vroegtijdig uit :)
is er iemand die weet hoe dit opgelost kan worden ??.
gr Wouter.
Hier het formulier.
<html>
<body>
<form action = "opdrachtenpercat.php" method = "POST">
<tr><td>
Selecteer categorie:
<td><SELECT NAME = Categorie value = >
<OPTION>Aanbouw en Nieuwbouw</OPTION>
<OPTION>Administratief/Secretarieel</OPTION>
<OPTION>Automatisering/Internet</OPTION>
<OPTION>Bestrating</OPTION>
<OPTION>Behang</OPTION>
<OPTION>Badkamer en Keukens</OPTION>
<OPTION>Beleid/Bestuur/Staf</OPTION>
<OPTION>Beveiliging/Defensie/Politie</OPTION>
<OPTION>Cv, Water en Gas</OPTION>
<OPTION>Commercieel/Verkoop</OPTION>
<OPTION>Consultancy/Advies</OPTION>
<OPTION>Daken en Goten</OPTION>
<OPTION>Design/Creatie/Journalistiek</OPTION>
<OPTION>Directie/Management algemeen</OPTION>
<OPTION>Elektra</OPTION>
<OPTION>Financieel/Accounting</OPTION>
<OPTION>Financiele dienstverlening</OPTION>
<OPTION>Gipswanden en Systeemplafonds</OPTION>
<OPTION>Horeca/Detailhandel</OPTION>
<OPTION>HR/Training/Opleiding</OPTION>
<OPTION>Isoleren</OPTION>
<OPTION>Inkoop/Verkoop/Logistiek</OPTION>
<OPTION>Juridisch</OPTION>
<OPTION>Kozijnen en Deuren</OPTION>
<OPTION>Klantenservice/Callcenter/Receptie</OPTION>
<OPTION>Lassers</OPTION>
<OPTION>Motor,Auto</OPTION>
<OPTION>Metselwerk en Voegen</OPTION>
<OPTION>Marketing/PR/Communicatie</OPTION>
<OPTION>Medisch/Zorg</OPTION>
<OPTION>Onderwijs/Onderzoek/Wetenschap</OPTION>
<OPTION>Overig</OPTION>
<OPTION>Productie/Uitvoerend</OPTION>
<OPTION>Schilderwerken</OPTION>
<OPTION>Sloopwerken</OPTION>
<OPTION>Stucadoren</OPTION>
<OPTION>Stofferen</OPTION>
<OPTION>Schoonmakers</OPTION>
<OPTION>Techniek</OPTION>
<OPTION>Transport</OPTION>
<OPTION>Tegels zetten</OPTION>
<OPTION>Timmerwerken</OPTION>
<OPTION>Tuin en Toebehoren</OPTION>
<OPTION>Vloeren</OPTION>
<OPTION>Verhuizen</OPTION>
</SELECT></td></tr>
<p><p><center><tr><td><input type = submit name = verzenden value = Zoek opdracht></center> </tr></td>
</body>
</html>
Hier het script met de navigatie.
Code (php)
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
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
<?php
$categorie = ($_POST['Categorie']);
mysql_connect ("xxxxxxx"xxxxxxx"xxxxx");
mysql_select_db("xxxxxxx");
//aantal records per pagina
$max = 20;
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
$start = ($max * $page) - $max;
//query maar 1x nodig.
$result = mysql_query("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$categorie' LIMIT " . $start . ", " . $max . "")or die (mysql_error());
//html tag <center> is outdated
echo"<center>";
//Begin nieuwe tabel
echo "<table border='1' BORDERCOLOR =#3ADF00>";
//Maak eerste rij
echo "<tr>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>Opdracht bekijken</th>
</tr>";
//hier je gegevens van je mysql ophalen
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td><a href = ''></a></td>";
echo "</tr>";
}
//Afsluiten van tabel buiten de while gehaald
echo "</table>";
//hier aan jou mysql gegevens aanpassen
//Categorie toegevoegd
$rows = mysql_result(mysql_query("SELECT COUNT(Opdracht_ID) FROM opdrachten_gegevens ORDER BY Opdracht_ID"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\">Vorige</a> ";
}
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
}
else {
echo "<b>" . $i . "</b>, ";
}
}
else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> ";
}
else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, ";
}
}
}
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">Volgende</a>";
}
echo "<p><a href='home.html'>Ok!</a>";
?>
$categorie = ($_POST['Categorie']);
mysql_connect ("xxxxxxx"xxxxxxx"xxxxx");
mysql_select_db("xxxxxxx");
//aantal records per pagina
$max = 20;
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
$start = ($max * $page) - $max;
//query maar 1x nodig.
$result = mysql_query("SELECT * FROM opdrachten_gegevens WHERE Categorie = '$categorie' LIMIT " . $start . ", " . $max . "")or die (mysql_error());
//html tag <center> is outdated
echo"<center>";
//Begin nieuwe tabel
echo "<table border='1' BORDERCOLOR =#3ADF00>";
//Maak eerste rij
echo "<tr>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>xxxxxxxx</th>
<th>Opdracht bekijken</th>
</tr>";
//hier je gegevens van je mysql ophalen
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td>" . $row['xxxxxxx'] . "</td>";
echo "<td><a href = ''></a></td>";
echo "</tr>";
}
//Afsluiten van tabel buiten de while gehaald
echo "</table>";
//hier aan jou mysql gegevens aanpassen
//Categorie toegevoegd
$rows = mysql_result(mysql_query("SELECT COUNT(Opdracht_ID) FROM opdrachten_gegevens ORDER BY Opdracht_ID"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\">Vorige</a> ";
}
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
}
else {
echo "<b>" . $i . "</b>, ";
}
}
else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> ";
}
else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, ";
}
}
}
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">Volgende</a>";
}
echo "<p><a href='home.html'>Ok!</a>";
?>