fout bij multiple request
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
include "connect.php"; //verbinding maken
// how many rows to show per page
$rowsPerPage = 30;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
if(isset($_REQUEST['search'])) // Zoeken op trefwoord
{
$search=$_REQUEST['search'];
$query = "SELECT COUNT(1) AS numrows FROM cat17 WHERE Familienaam LIKE '%$search%' || Auteur LIKE '%$search%' || Titel LIKE '%$search%'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$query = "SELECT * FROM cat17 WHERE Familienaam LIKE '%$search%' || Auteur LIKE '%$search%' || Titel LIKE '%$search%' LIMIT $offset, $rowsPerPage";
}
else if(isset($_REQUEST['letter'])) // Zoeken op letter
{
$letter = $_REQUEST['letter'];
$query = "SELECT COUNT(1) AS numrows FROM cat17 WHERE Familienaam LIKE '$letter%'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$query = "SELECT * FROM cat17 WHERE Familienaam LIKE '$letter%' LIMIT $offset, $rowsPerPage";
}
else{ // de complete database
$query = "SELECT COUNT(*) AS numrows FROM cat17";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$query = "SELECT * FROM cat17"." LIMIT $offset, $rowsPerPage";
}
$sql = mysql_query($query) or die ( mysql_error( ) );
echo"<table width=\"100%\" border=0>";
while($row = mysql_fetch_array($sql)){
echo"<tr><td width=\"130\" valign=\"top\"><b>Familienaam:</b></td><td valign=\"top\">".$row['Familienaam']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Auteur:</b></td><td valign=\"top\">".$row['Auteur']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Titel:</b></td><td valign=\"top\">".$row['Titel']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Nummer:</b></td><td valign=\"top\">".$row['Nummer']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Prijs:</b></td><td valign=\"top\">".$row['Prijs']."</td></tr>";
echo"<tr><td colspan=\"2\"><hr></td></tr>";
}
echo"</table><br>";
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
$self = $_SERVER['PHP_SELF'];
// creating 'previous' and 'next' link
// plus 'first page' and 'last page' link
// print 'previous' link only if we're not
// on page one
if ($pageNum > 1)
{
$page = $pageNum - 1;
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : null;
$letter = isset($_REQUEST['letter']) ? $_REQUEST['letter'] : null;
$prev = " <a href=\"$self?page=$page&search=$search&letter=$letter\">[Prev]</a> ";
$first = " <a href=\"$self?page=1&search=$search&letter=$letter\">[First Page]</a> ";
}
else
{
$prev = ' [Prev] '; // we're on page one, don't enable 'previous' link
$first = ' [First Page] '; // nor 'first page' link
}
// print 'next' link only if we're not
// on the last page
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : null;
$letter = isset($_REQUEST['letter']) ? $_REQUEST['letter'] : null;
$next = " <a href=\"$self?page=$page&search=$search&letter=$letter\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage&search=$search&letter=$letter\">[Last Page]</a> ";
}
else
{
$next = ' [Next] '; // we're on the last page, don't enable 'next' link
$last = ' [Last Page] '; // nor 'last page' link
}
// print the page navigation link
echo "<table width=\"100%\"><tr><td>" . $first . $prev . "</td><td align=\"center\"> Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages </td><td align=\"right\">" . $next . $last . "</td></tr></table>";
?>
include "connect.php"; //verbinding maken
// how many rows to show per page
$rowsPerPage = 30;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
if(isset($_REQUEST['search'])) // Zoeken op trefwoord
{
$search=$_REQUEST['search'];
$query = "SELECT COUNT(1) AS numrows FROM cat17 WHERE Familienaam LIKE '%$search%' || Auteur LIKE '%$search%' || Titel LIKE '%$search%'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$query = "SELECT * FROM cat17 WHERE Familienaam LIKE '%$search%' || Auteur LIKE '%$search%' || Titel LIKE '%$search%' LIMIT $offset, $rowsPerPage";
}
else if(isset($_REQUEST['letter'])) // Zoeken op letter
{
$letter = $_REQUEST['letter'];
$query = "SELECT COUNT(1) AS numrows FROM cat17 WHERE Familienaam LIKE '$letter%'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$query = "SELECT * FROM cat17 WHERE Familienaam LIKE '$letter%' LIMIT $offset, $rowsPerPage";
}
else{ // de complete database
$query = "SELECT COUNT(*) AS numrows FROM cat17";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$query = "SELECT * FROM cat17"." LIMIT $offset, $rowsPerPage";
}
$sql = mysql_query($query) or die ( mysql_error( ) );
echo"<table width=\"100%\" border=0>";
while($row = mysql_fetch_array($sql)){
echo"<tr><td width=\"130\" valign=\"top\"><b>Familienaam:</b></td><td valign=\"top\">".$row['Familienaam']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Auteur:</b></td><td valign=\"top\">".$row['Auteur']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Titel:</b></td><td valign=\"top\">".$row['Titel']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Nummer:</b></td><td valign=\"top\">".$row['Nummer']."</td></tr>";
echo"<tr><td valign=\"top\"><b>Prijs:</b></td><td valign=\"top\">".$row['Prijs']."</td></tr>";
echo"<tr><td colspan=\"2\"><hr></td></tr>";
}
echo"</table><br>";
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
$self = $_SERVER['PHP_SELF'];
// creating 'previous' and 'next' link
// plus 'first page' and 'last page' link
// print 'previous' link only if we're not
// on page one
if ($pageNum > 1)
{
$page = $pageNum - 1;
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : null;
$letter = isset($_REQUEST['letter']) ? $_REQUEST['letter'] : null;
$prev = " <a href=\"$self?page=$page&search=$search&letter=$letter\">[Prev]</a> ";
$first = " <a href=\"$self?page=1&search=$search&letter=$letter\">[First Page]</a> ";
}
else
{
$prev = ' [Prev] '; // we're on page one, don't enable 'previous' link
$first = ' [First Page] '; // nor 'first page' link
}
// print 'next' link only if we're not
// on the last page
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : null;
$letter = isset($_REQUEST['letter']) ? $_REQUEST['letter'] : null;
$next = " <a href=\"$self?page=$page&search=$search&letter=$letter\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage&search=$search&letter=$letter\">[Last Page]</a> ";
}
else
{
$next = ' [Next] '; // we're on the last page, don't enable 'next' link
$last = ' [Last Page] '; // nor 'last page' link
}
// print the page navigation link
echo "<table width=\"100%\"><tr><td>" . $first . $prev . "</td><td align=\"center\"> Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages </td><td align=\"right\">" . $next . $last . "</td></tr></table>";
?>
waarom gebruik je dan niet gewoon
elseif(isset($_REQUEST['letter']))
let wel op dat je dan je { en } nog gelijk en goed hebt staan
Maar goed, het probleem is nog niet opgelost...
Elmer
Elmer:
Sorry lads.. ik heb het probleem al opgelostgroet,
Elmer
Elmer
Gaarne altijd de oplossing vermelden voor de andere lezers.
if(isset($_REQUEST['search']))
{
$search=$_REQUEST['search'];
}
if(isset($_REQUEST['search']) && $search != null)
{ etc.}