a-b-c-links-pagina-1-2-3-en-sorteren
Gesponsorde koppelingen
PHP script bestanden
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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
<?php
$host = "localhost"; // MySql Host
$gebruiker = ""; // Gebruikersnaam om in de database te komen
$wachtwoord = ""; // Wachtwoord om in de database te komen
$database = ""; // Datebase naam
mysql_connect($host, $gebruiker, $wachtwoord) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
$letter = $_GET['letter'];
$aantal_leden = 25;
if(isset($_GET['sorteren']))
{
switch($_GET['sorteren'])
{
case "naam": $sorteer = "naam"; break;
case "email": $sorteer = "email"; break;
default: $sorteer = "naam"; break;
}
}
else
{
$sorteer = "naam";
}
if (isset($_GET['type']) && ($_GET['sorteren']))
{
$type = $_GET['type'];
if ($type == "ASC")
{
$type = "DESC";
}
else
{
$type = "ASC";
}
}
else
{
$type = "ASC";
}
$sql = "SELECT COUNT(*) AS `totaal` FROM `leden` WHERE `naam` LIKE '".addslashes($letter)."%'";
$res = mysql_query ($sql) or die (mysql_error ());
$list = mysql_fetch_assoc($res);
$aantal = $list['totaal'];
if(isset($_GET['id']) && (is_numeric($_GET['id'])))
{
$id = $_GET['id'];
}
else
{
$id = 0;
}
echo "<a href=\"".$_SERVER['PHP_SELF']."?letter=tekens\">#</a> | ";
for ($i = 65 ; $i < 91 ; $i++)
{
echo "<a href=\"".$_SERVER['PHP_SELF']."?letter=".urlencode(chr($i))."\">".chr($i)."</a> | ";
}
echo "<a href=\"".$_SERVER['PHP_SELF']."\">Alles</a>\n<br />\n<br />\n<hr\n><br />\n";
if($letter == "tekens")
{
$sql = "SELECT * FROM `leden` WHERE `naam` NOT REGEXP '^[a-z]' ORDER BY ".$sorteer." ".$type." LIMIT ".addslashes($id).", ".$aantal_leden."";
}
else
{
$sql = "SELECT * FROM `leden` WHERE `naam` LIKE '".$letter."%' ORDER BY ".$sorteer." ".$type." LIMIT ".addslashes($id).", ".$aantal_leden."";
}
$query = mysql_query($sql);
if(mysql_num_rows($query) == 0)
{
if(isset($_GET['letter']))
{
echo "</table>
<p style=\"text-align: center;\">Er zijn geen Leden gevonden met de letter ".$_GET['letter']."</p>";
}
else
{
echo "</table>
<p style=\"text-align: center;\">Er zijn nog geen leden toegevoegd!</p>";
}
}
else
{
?>
<table border="0" cellpadding="1" cellspacing="0" width="90%">
<tr>
<td><b><a href="<?php echo $_SERVER['PHP_SELF']."?letter=".urlencode($letter)."&sorteren=naam&type=".urlencode($type);?>">Naam</a></b></td>
<td><b><a href="<?php echo $_SERVER['PHP_SELF']."?letter=".urlencode($letter)."&sorteren=email&type=".urlencode($type);?>">Email</a></b></td>
<td><b>Toegevoegd op</b></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php
while($list = mysql_fetch_assoc($query))
{
echo "<tr>
<td>".ucfirst($list['naam'])."</td>
<td>".$list['email']."</td>
<td>".$list['toegevoegd']."</td>
</tr>";
}
echo "<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr>";
$paginas = $aantal / $aantal_leden;
if($paginas > 1)
{
echo "
<p style=\"text-align: center;\">
<br />
Pagina's ";
for ($i = 0; $i < $aantal; $i += $aantal_leden)
{
$pagina = $i / $aantal_leden + 1;
echo "<a href=\"".$_SERVER['PHP_SELF']."?letter=".urlencode($letter)."&id=".urlencode($i)."&sorteren=".urlencode($_GET['sorteren'])."&type=".urlencode($_GET['type'])."\">".$pagina." | </a> ";
}
}
}
?>
$host = "localhost"; // MySql Host
$gebruiker = ""; // Gebruikersnaam om in de database te komen
$wachtwoord = ""; // Wachtwoord om in de database te komen
$database = ""; // Datebase naam
mysql_connect($host, $gebruiker, $wachtwoord) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
$letter = $_GET['letter'];
$aantal_leden = 25;
if(isset($_GET['sorteren']))
{
switch($_GET['sorteren'])
{
case "naam": $sorteer = "naam"; break;
case "email": $sorteer = "email"; break;
default: $sorteer = "naam"; break;
}
}
else
{
$sorteer = "naam";
}
if (isset($_GET['type']) && ($_GET['sorteren']))
{
$type = $_GET['type'];
if ($type == "ASC")
{
$type = "DESC";
}
else
{
$type = "ASC";
}
}
else
{
$type = "ASC";
}
$sql = "SELECT COUNT(*) AS `totaal` FROM `leden` WHERE `naam` LIKE '".addslashes($letter)."%'";
$res = mysql_query ($sql) or die (mysql_error ());
$list = mysql_fetch_assoc($res);
$aantal = $list['totaal'];
if(isset($_GET['id']) && (is_numeric($_GET['id'])))
{
$id = $_GET['id'];
}
else
{
$id = 0;
}
echo "<a href=\"".$_SERVER['PHP_SELF']."?letter=tekens\">#</a> | ";
for ($i = 65 ; $i < 91 ; $i++)
{
echo "<a href=\"".$_SERVER['PHP_SELF']."?letter=".urlencode(chr($i))."\">".chr($i)."</a> | ";
}
echo "<a href=\"".$_SERVER['PHP_SELF']."\">Alles</a>\n<br />\n<br />\n<hr\n><br />\n";
if($letter == "tekens")
{
$sql = "SELECT * FROM `leden` WHERE `naam` NOT REGEXP '^[a-z]' ORDER BY ".$sorteer." ".$type." LIMIT ".addslashes($id).", ".$aantal_leden."";
}
else
{
$sql = "SELECT * FROM `leden` WHERE `naam` LIKE '".$letter."%' ORDER BY ".$sorteer." ".$type." LIMIT ".addslashes($id).", ".$aantal_leden."";
}
$query = mysql_query($sql);
if(mysql_num_rows($query) == 0)
{
if(isset($_GET['letter']))
{
echo "</table>
<p style=\"text-align: center;\">Er zijn geen Leden gevonden met de letter ".$_GET['letter']."</p>";
}
else
{
echo "</table>
<p style=\"text-align: center;\">Er zijn nog geen leden toegevoegd!</p>";
}
}
else
{
?>
<table border="0" cellpadding="1" cellspacing="0" width="90%">
<tr>
<td><b><a href="<?php echo $_SERVER['PHP_SELF']."?letter=".urlencode($letter)."&sorteren=naam&type=".urlencode($type);?>">Naam</a></b></td>
<td><b><a href="<?php echo $_SERVER['PHP_SELF']."?letter=".urlencode($letter)."&sorteren=email&type=".urlencode($type);?>">Email</a></b></td>
<td><b>Toegevoegd op</b></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php
while($list = mysql_fetch_assoc($query))
{
echo "<tr>
<td>".ucfirst($list['naam'])."</td>
<td>".$list['email']."</td>
<td>".$list['toegevoegd']."</td>
</tr>";
}
echo "<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr>";
$paginas = $aantal / $aantal_leden;
if($paginas > 1)
{
echo "
<p style=\"text-align: center;\">
<br />
Pagina's ";
for ($i = 0; $i < $aantal; $i += $aantal_leden)
{
$pagina = $i / $aantal_leden + 1;
echo "<a href=\"".$_SERVER['PHP_SELF']."?letter=".urlencode($letter)."&id=".urlencode($i)."&sorteren=".urlencode($_GET['sorteren'])."&type=".urlencode($_GET['type'])."\">".$pagina." | </a> ";
}
}
}
?>