Zoekfunctie weergave werkt niet goed
<!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>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
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
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
<?php
error_reporting(E_ALL);
$server = mysql_connect("localhost") or die("Kan server niet vinden! ". mysql_error());
mysql_select_db("sch", $server) or die("Kan database niet selecteren! ". mysql_error());
if($_POST['zoek'])
{
$zoek = $_POST['zoek'];
$sql = "SELECT * FROM klanten WHERE kl_achternaam LIKE '%" . $zoek ."%' OR (kl_bedrijfsnaam) LIKE '%" . $zoek . "%'
OR (kl_straatnaam) LIKE '%" . $zoek . "%'";
$resultaat = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($resultaat);
if(empty($num))
{
echo "" . $zoek . " werd niet gevonden...";
}
else
{
echo "Resultaten:";
echo "<strong>";
echo " ";
echo $num;
echo " ";
echo "records gevonden.";
echo "</strong>";
echo "<br/><br/>";
echo "<table width='200' border='1'>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>Bedrijfsnaam</td>";
echo "<td>Aanhef</td>";
echo "<td>Voorletter</td>";
echo "<td>Voorvoegsel</td>";
echo "<td>Achternaam</td>";
echo "<td>Straatnaam</td>";
echo "<td>Huisnummer</td>";
echo "<td>Postcode</td>";
echo "<td>Woonplaats</td>";
echo "<td>Telefoonnr</td>";
echo "<td>Telefoonwerk</td>";
echo "<td>Mobielnr</td>";
echo "<td>Faxnr</td>";
echo "<td>Email</td>";
echo "<td>Nieuwsbrief</td>";
echo "<td>Opmerking</td>";
echo "</tr>";
echo "</table>";
while($row = mysql_fetch_object($resultaat))
{
echo "<table border='1' width='200'>";
echo "<tr><td>";
echo $row->kl_klantennr;
echo "</td><td>";
echo $row->kl_bedrijfsnaam;
echo "</td><td>";
echo $row->kl_aanhef;
echo "</td><td>";
echo $row->kl_voorletters;
echo "</td><td>";
echo $row->kl_tussenvoegsel;
echo "</td><td>";
echo $row->kl_achternaam;
echo "</td><td>";
echo $row->kl_straatnaam;
echo "</td><td>";
echo $row->kl_huisnummer;
echo "</td><td>";
echo $row->kl_postcode;
echo "</td><td>";
echo $row->kl_woonplaats;
echo "</td><td>";
echo $row->kl_telefoonnrthuis;
echo "</td><td>";
echo $row->kl_telefoonnrwerk;
echo "</td><td>";
echo $row->kl_mobielnr;
echo "</td><td>";
echo $row->kl_faxnr;
echo "</td><td>";
echo $row->kl_email;
echo "</td><td>";
echo $row->kl_nieuwdbrief;
echo "</td><td>";
echo $row->kl_opmerking;
echo "</td></tr>";
echo "</table>";
}
echo "<br><br>";
}
}
?>
error_reporting(E_ALL);
$server = mysql_connect("localhost") or die("Kan server niet vinden! ". mysql_error());
mysql_select_db("sch", $server) or die("Kan database niet selecteren! ". mysql_error());
if($_POST['zoek'])
{
$zoek = $_POST['zoek'];
$sql = "SELECT * FROM klanten WHERE kl_achternaam LIKE '%" . $zoek ."%' OR (kl_bedrijfsnaam) LIKE '%" . $zoek . "%'
OR (kl_straatnaam) LIKE '%" . $zoek . "%'";
$resultaat = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($resultaat);
if(empty($num))
{
echo "" . $zoek . " werd niet gevonden...";
}
else
{
echo "Resultaten:";
echo "<strong>";
echo " ";
echo $num;
echo " ";
echo "records gevonden.";
echo "</strong>";
echo "<br/><br/>";
echo "<table width='200' border='1'>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>Bedrijfsnaam</td>";
echo "<td>Aanhef</td>";
echo "<td>Voorletter</td>";
echo "<td>Voorvoegsel</td>";
echo "<td>Achternaam</td>";
echo "<td>Straatnaam</td>";
echo "<td>Huisnummer</td>";
echo "<td>Postcode</td>";
echo "<td>Woonplaats</td>";
echo "<td>Telefoonnr</td>";
echo "<td>Telefoonwerk</td>";
echo "<td>Mobielnr</td>";
echo "<td>Faxnr</td>";
echo "<td>Email</td>";
echo "<td>Nieuwsbrief</td>";
echo "<td>Opmerking</td>";
echo "</tr>";
echo "</table>";
while($row = mysql_fetch_object($resultaat))
{
echo "<table border='1' width='200'>";
echo "<tr><td>";
echo $row->kl_klantennr;
echo "</td><td>";
echo $row->kl_bedrijfsnaam;
echo "</td><td>";
echo $row->kl_aanhef;
echo "</td><td>";
echo $row->kl_voorletters;
echo "</td><td>";
echo $row->kl_tussenvoegsel;
echo "</td><td>";
echo $row->kl_achternaam;
echo "</td><td>";
echo $row->kl_straatnaam;
echo "</td><td>";
echo $row->kl_huisnummer;
echo "</td><td>";
echo $row->kl_postcode;
echo "</td><td>";
echo $row->kl_woonplaats;
echo "</td><td>";
echo $row->kl_telefoonnrthuis;
echo "</td><td>";
echo $row->kl_telefoonnrwerk;
echo "</td><td>";
echo $row->kl_mobielnr;
echo "</td><td>";
echo $row->kl_faxnr;
echo "</td><td>";
echo $row->kl_email;
echo "</td><td>";
echo $row->kl_nieuwdbrief;
echo "</td><td>";
echo $row->kl_opmerking;
echo "</td></tr>";
echo "</table>";
}
echo "<br><br>";
}
}
?>
<form id="zoek" name="zoek" method="post" action="">
<table width="200" border="1" align="center">
<tr>
<td>zoek</td>
<td><input name="zoek" type="text" id="zoek" style="background-color:#D0D0D0; border:1px solid;" /></td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" name="Submit" value="zoek" /></center></td>
</tr>
</table>
</form>
</body>
</html>
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
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
<?php
echo "<table width='200' border='1'>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>Bedrijfsnaam</td>";
echo "<td>Aanhef</td>";
echo "<td>Voorletter</td>";
echo "<td>Voorvoegsel</td>";
echo "<td>Achternaam</td>";
echo "<td>Straatnaam</td>";
echo "<td>Huisnummer</td>";
echo "<td>Postcode</td>";
echo "<td>Woonplaats</td>";
echo "<td>Telefoonnr</td>";
echo "<td>Telefoonwerk</td>";
echo "<td>Mobielnr</td>";
echo "<td>Faxnr</td>";
echo "<td>Email</td>";
echo "<td>Nieuwsbrief</td>";
echo "<td>Opmerking</td>";
echo "</tr>";
echo "</table>";
while($row = mysql_fetch_object($resultaat))
{
echo "<table border='1' width='200'>";
echo "<tr><td>";
echo $row->kl_klantennr;
echo "</td><td>";
echo $row->kl_bedrijfsnaam;
echo "</td><td>";
echo $row->kl_aanhef;
echo "</td><td>";
echo $row->kl_voorletters;
echo "</td><td>";
echo $row->kl_tussenvoegsel;
echo "</td><td>";
echo $row->kl_achternaam;
echo "</td><td>";
echo $row->kl_straatnaam;
echo "</td><td>";
echo $row->kl_huisnummer;
echo "</td><td>";
echo $row->kl_postcode;
echo "</td><td>";
echo $row->kl_woonplaats;
echo "</td><td>";
echo $row->kl_telefoonnrthuis;
echo "</td><td>";
echo $row->kl_telefoonnrwerk;
echo "</td><td>";
echo $row->kl_mobielnr;
echo "</td><td>";
echo $row->kl_faxnr;
echo "</td><td>";
echo $row->kl_email;
echo "</td><td>";
echo $row->kl_nieuwdbrief;
echo "</td><td>";
echo $row->kl_opmerking;
echo "</td></tr>";
echo "</table>";
}
echo "<br><br>";
?>
echo "<table width='200' border='1'>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>Bedrijfsnaam</td>";
echo "<td>Aanhef</td>";
echo "<td>Voorletter</td>";
echo "<td>Voorvoegsel</td>";
echo "<td>Achternaam</td>";
echo "<td>Straatnaam</td>";
echo "<td>Huisnummer</td>";
echo "<td>Postcode</td>";
echo "<td>Woonplaats</td>";
echo "<td>Telefoonnr</td>";
echo "<td>Telefoonwerk</td>";
echo "<td>Mobielnr</td>";
echo "<td>Faxnr</td>";
echo "<td>Email</td>";
echo "<td>Nieuwsbrief</td>";
echo "<td>Opmerking</td>";
echo "</tr>";
echo "</table>";
while($row = mysql_fetch_object($resultaat))
{
echo "<table border='1' width='200'>";
echo "<tr><td>";
echo $row->kl_klantennr;
echo "</td><td>";
echo $row->kl_bedrijfsnaam;
echo "</td><td>";
echo $row->kl_aanhef;
echo "</td><td>";
echo $row->kl_voorletters;
echo "</td><td>";
echo $row->kl_tussenvoegsel;
echo "</td><td>";
echo $row->kl_achternaam;
echo "</td><td>";
echo $row->kl_straatnaam;
echo "</td><td>";
echo $row->kl_huisnummer;
echo "</td><td>";
echo $row->kl_postcode;
echo "</td><td>";
echo $row->kl_woonplaats;
echo "</td><td>";
echo $row->kl_telefoonnrthuis;
echo "</td><td>";
echo $row->kl_telefoonnrwerk;
echo "</td><td>";
echo $row->kl_mobielnr;
echo "</td><td>";
echo $row->kl_faxnr;
echo "</td><td>";
echo $row->kl_email;
echo "</td><td>";
echo $row->kl_nieuwdbrief;
echo "</td><td>";
echo $row->kl_opmerking;
echo "</td></tr>";
echo "</table>";
}
echo "<br><br>";
?>
...niet zo...
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
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
<?php
echo "<table width='200' border='1'>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>Bedrijfsnaam</td>";
echo "<td>Aanhef</td>";
echo "<td>Voorletter</td>";
echo "<td>Voorvoegsel</td>";
echo "<td>Achternaam</td>";
echo "<td>Straatnaam</td>";
echo "<td>Huisnummer</td>";
echo "<td>Postcode</td>";
echo "<td>Woonplaats</td>";
echo "<td>Telefoonnr</td>";
echo "<td>Telefoonwerk</td>";
echo "<td>Mobielnr</td>";
echo "<td>Faxnr</td>";
echo "<td>Email</td>";
echo "<td>Nieuwsbrief</td>";
echo "<td>Opmerking</td>";
echo "</tr>";
while($row = mysql_fetch_object($resultaat))
{
echo "<tr><td>";
echo $row->kl_klantennr;
echo "</td><td>";
echo $row->kl_bedrijfsnaam;
echo "</td><td>";
echo $row->kl_aanhef;
echo "</td><td>";
echo $row->kl_voorletters;
echo "</td><td>";
echo $row->kl_tussenvoegsel;
echo "</td><td>";
echo $row->kl_achternaam;
echo "</td><td>";
echo $row->kl_straatnaam;
echo "</td><td>";
echo $row->kl_huisnummer;
echo "</td><td>";
echo $row->kl_postcode;
echo "</td><td>";
echo $row->kl_woonplaats;
echo "</td><td>";
echo $row->kl_telefoonnrthuis;
echo "</td><td>";
echo $row->kl_telefoonnrwerk;
echo "</td><td>";
echo $row->kl_mobielnr;
echo "</td><td>";
echo $row->kl_faxnr;
echo "</td><td>";
echo $row->kl_email;
echo "</td><td>";
echo $row->kl_nieuwdbrief;
echo "</td><td>";
echo $row->kl_opmerking;
echo "</td></tr>";
}
echo "</table>";
echo "<br><br>";
?>
echo "<table width='200' border='1'>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>Bedrijfsnaam</td>";
echo "<td>Aanhef</td>";
echo "<td>Voorletter</td>";
echo "<td>Voorvoegsel</td>";
echo "<td>Achternaam</td>";
echo "<td>Straatnaam</td>";
echo "<td>Huisnummer</td>";
echo "<td>Postcode</td>";
echo "<td>Woonplaats</td>";
echo "<td>Telefoonnr</td>";
echo "<td>Telefoonwerk</td>";
echo "<td>Mobielnr</td>";
echo "<td>Faxnr</td>";
echo "<td>Email</td>";
echo "<td>Nieuwsbrief</td>";
echo "<td>Opmerking</td>";
echo "</tr>";
while($row = mysql_fetch_object($resultaat))
{
echo "<tr><td>";
echo $row->kl_klantennr;
echo "</td><td>";
echo $row->kl_bedrijfsnaam;
echo "</td><td>";
echo $row->kl_aanhef;
echo "</td><td>";
echo $row->kl_voorletters;
echo "</td><td>";
echo $row->kl_tussenvoegsel;
echo "</td><td>";
echo $row->kl_achternaam;
echo "</td><td>";
echo $row->kl_straatnaam;
echo "</td><td>";
echo $row->kl_huisnummer;
echo "</td><td>";
echo $row->kl_postcode;
echo "</td><td>";
echo $row->kl_woonplaats;
echo "</td><td>";
echo $row->kl_telefoonnrthuis;
echo "</td><td>";
echo $row->kl_telefoonnrwerk;
echo "</td><td>";
echo $row->kl_mobielnr;
echo "</td><td>";
echo $row->kl_faxnr;
echo "</td><td>";
echo $row->kl_email;
echo "</td><td>";
echo $row->kl_nieuwdbrief;
echo "</td><td>";
echo $row->kl_opmerking;
echo "</td></tr>";
}
echo "</table>";
echo "<br><br>";
?>
Dus in 1 tabel.
Let tevens op het vele malen aanroepen van de echo. Het aanroepen van echo kost extra tijd. Het werkt zo wel, maar qua performance kan je het beste bijvoorbeeld alles in 1 keer echo'en
Nu werkt die redelijk goed... Alleen moet ik nog wat verzinnen op de grote van bedrijfsnamen etc.