T Else error
ik ben bezig om op een pagina informatie uit de database te selecteren op invoer,
voorbeeld: in de database staat onder depicao de value "EHAM" en ook allemaal andere. dan mag hij op deze pagina alleen de invoer van EHAM laten zien.
Maar ik krijg een T else error.
Ziet iemand de fout?
Quote:
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
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
<?php
@define ("MYSQL_CONNECT_INCLUDE", "connect_db.php");
include(MYSQL_CONNECT_INCLUDE);
$query = "SELECT * FROM v1_acarsdata ORDER BY depicao";
$result = mysql_query($query);
$number = mysql_numrows($result);
$aankomst2 = mysql_result($result,$i, "depicao");
if ($aankomst2 = 'EHAM') {
print "<table>";
print "<tr>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Vluchtnummer</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Piloot</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Vertrek</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Aankomst</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Verwacht</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Status</b></font></td>";
print "</tr>";
for ($i=0; $i<$number; $i++) {
$piloot = mysql_result($result,$i,"pilotname");
$vliegnummer = mysql_result($result,$i, "flightnum");
$vertrek = mysql_result($result,$i, "depapt");
$aankomst = mysql_result($result,$i, "arrapt");
$verwacht = mysql_result($result,$i, "arrtime");
$tegaan = mysql_result($result,$i, "timeremaining");
$status = mysql_result($result,$i, "phasedetail");
$status1 = mysql_result($result,$i, "phasedetail");
print "<tr>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$vliegnummer</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$piloot</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$vertrek</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$aankomst</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$verwacht ($tegaan)</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$status</font></td>";
print "</tr>";
} else {
print "<table>";
print "<tr>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>EHAM</b></font></td>";
print "</tr>";
print "<tr>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>Geen vluchten gevonden</font></td>";
print "</tr>";
}
}
print "</table>";
}
mysql_close();
?>
@define ("MYSQL_CONNECT_INCLUDE", "connect_db.php");
include(MYSQL_CONNECT_INCLUDE);
$query = "SELECT * FROM v1_acarsdata ORDER BY depicao";
$result = mysql_query($query);
$number = mysql_numrows($result);
$aankomst2 = mysql_result($result,$i, "depicao");
if ($aankomst2 = 'EHAM') {
print "<table>";
print "<tr>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Vluchtnummer</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Piloot</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Vertrek</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Aankomst</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Verwacht</b></font></td>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>Status</b></font></td>";
print "</tr>";
for ($i=0; $i<$number; $i++) {
$piloot = mysql_result($result,$i,"pilotname");
$vliegnummer = mysql_result($result,$i, "flightnum");
$vertrek = mysql_result($result,$i, "depapt");
$aankomst = mysql_result($result,$i, "arrapt");
$verwacht = mysql_result($result,$i, "arrtime");
$tegaan = mysql_result($result,$i, "timeremaining");
$status = mysql_result($result,$i, "phasedetail");
$status1 = mysql_result($result,$i, "phasedetail");
print "<tr>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$vliegnummer</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$piloot</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$vertrek</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$aankomst</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$verwacht ($tegaan)</font></td>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>$status</font></td>";
print "</tr>";
} else {
print "<table>";
print "<tr>";
print "<td bgcolor=#58B1D6 width=100 height=12 align=left><font face=Arial color=#FFFFFF size=1><b>EHAM</b></font></td>";
print "</tr>";
print "<tr>";
print "<td width=100 height=12 align=left><font face=Arial size=1 color=#000000>Geen vluchten gevonden</font></td>";
print "</tr>";
}
}
print "</table>";
}
mysql_close();
?>
Gewijzigd op 19/06/2011 00:08:14 door JElle vd Werff
Verder:
- Waarom een @ (foutonderdrukking) voor de define?
- Waarom het bestand in de define?
- Selecteer wat je wilt hebben, gebruik geen *.
- Bouw foutafhandeling in, kijk wat mysql_query teruggeeft.
- Maak gebruik van zinnige variabele namen, $aankomst2?
- Maak gebruik van CSS.
- Maak gebruik van mysql_fetch_assoc.
- Tel je accolades.
moet zijn
if ($aankomst2 == 'EHAM') {
Jij springt bij de één wel in en bij de andere weer niet, als je overal even een duidelijk structuur maakt zie je de fout direct, de ELSE komt onverwacht dus daarvoor doe je iets fout, en pas natuurlijk de punten van Karl en SanThe toe.