kan geen data uit db halen
if($data['type'] == '1'){
elseif($data['type'] == '2'){
uit table users
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
include '../includes/config.php';
echo "<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval('showContent()', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$('.show_content').load('../assets/ajax/timer.php').fadeIn(1000);
}
</script>
<?php
echo "<table width=100% align=\"center\" cellspacing=\"0\" cellPadding=2 border=\"1\" borderColor=\"black\">\n";
echo "<tr><td class=\"subTitle\" align=\"center\"><b>Construction Yard</b></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Click Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Referal Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='username here' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "</table>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>personal Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Click Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Username:</td><td class=\"mainTxt\" width=\"25%\">username</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Clicks</td><td class=\"mainTxt\" width=\"25%\">Total Clicks</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">E-mail:</td><td class=\"mainTxt\" width=\"25%\">email</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Referals</td><td class=\"mainTxt\" width=\"25%\">Total Referals</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Signup IP:</td><td class=\"mainTxt\" width=\"25%\">ip</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Untrained Units</td><td class=\"mainTxt\" width=\"25%\">Total Untrained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Gender:</td><td class=\"mainTxt\" width=\"25%\">gender</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Trained Units:</td><td class=\"mainTxt\" width=\"25%\">Total Trained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
//include "functions.php"; eventueel in een functie zetten dat ik $data overal kan gebruiken ?
$sql = 'SELECT type from users where username="username"';
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 2) {
echo '[A]<br>';
while ($data = mysqli_fetch_assoc($result)) {
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"gold\">GDI</font></a></td>\n";
echo "<td> </td>\n";
}
}
else
{
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"RED\">NOD</font></a></td>\n";
echo "<td> </td>\n";
}
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><img src=\"" . $data['avatar'] . "\" class=\"img_avatar\" alt=\"Avatar\" /></a></td>\n";
echo "<td> </td>\n";
if ($data['type'] == '1') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/gdi.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
elseif($data['type'] == '2') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/nod.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Building Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>infantrie Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>vehicle Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>air Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>atack Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>defence Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "</ul>\n\n";
echo "</li>\n";
echo "<li class='bar'></li>\n";
echo "</ul>\n\n";
mysqli_close($link);
?>
include '../includes/config.php';
echo "<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval('showContent()', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$('.show_content').load('../assets/ajax/timer.php').fadeIn(1000);
}
</script>
<?php
echo "<table width=100% align=\"center\" cellspacing=\"0\" cellPadding=2 border=\"1\" borderColor=\"black\">\n";
echo "<tr><td class=\"subTitle\" align=\"center\"><b>Construction Yard</b></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Click Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Referal Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='username here' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "</table>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>personal Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Click Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Username:</td><td class=\"mainTxt\" width=\"25%\">username</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Clicks</td><td class=\"mainTxt\" width=\"25%\">Total Clicks</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">E-mail:</td><td class=\"mainTxt\" width=\"25%\">email</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Referals</td><td class=\"mainTxt\" width=\"25%\">Total Referals</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Signup IP:</td><td class=\"mainTxt\" width=\"25%\">ip</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Untrained Units</td><td class=\"mainTxt\" width=\"25%\">Total Untrained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Gender:</td><td class=\"mainTxt\" width=\"25%\">gender</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Trained Units:</td><td class=\"mainTxt\" width=\"25%\">Total Trained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
//include "functions.php"; eventueel in een functie zetten dat ik $data overal kan gebruiken ?
$sql = 'SELECT type from users where username="username"';
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 2) {
echo '[A]<br>';
while ($data = mysqli_fetch_assoc($result)) {
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"gold\">GDI</font></a></td>\n";
echo "<td> </td>\n";
}
}
else
{
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"RED\">NOD</font></a></td>\n";
echo "<td> </td>\n";
}
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><img src=\"" . $data['avatar'] . "\" class=\"img_avatar\" alt=\"Avatar\" /></a></td>\n";
echo "<td> </td>\n";
if ($data['type'] == '1') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/gdi.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
elseif($data['type'] == '2') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/nod.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Building Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>infantrie Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>vehicle Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>air Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>atack Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>defence Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "</ul>\n\n";
echo "</li>\n";
echo "<li class='bar'></li>\n";
echo "</ul>\n\n";
mysqli_close($link);
?>
Gewijzigd op 11/09/2019 17:12:12 door Yannick decock
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
include '../includes/config.php';
$sql = 'SELECT type from users where username="username"';
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 2) {
echo '[A]<br>';
while ($data = mysqli_fetch_assoc($result)) {
echo '[result]<br>';
}
} else {
echo '[B]<br>';
}
// het is hier NIET langer gegarandeerd dat je resultaten hebt!
if ($data['type'] == '1') {
echo '[type 1]<br>';
} elseif($data['type'] == '2') {
echo '[type 2]<br>';
}
mysqli_close($link);
?>[end]
include '../includes/config.php';
$sql = 'SELECT type from users where username="username"';
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 2) {
echo '[A]<br>';
while ($data = mysqli_fetch_assoc($result)) {
echo '[result]<br>';
}
} else {
echo '[B]<br>';
}
// het is hier NIET langer gegarandeerd dat je resultaten hebt!
if ($data['type'] == '1') {
echo '[type 1]<br>';
} elseif($data['type'] == '2') {
echo '[type 2]<br>';
}
mysqli_close($link);
?>[end]
Wat zie je achtereenvolgens op het scherm. En let op regel 16 en verder: het is helemaal niet gegarandeerd dat je hier query-resultaten hebt... en dus dat $data uberhaupt bestaat.
Verder lijkt het mij ook geen goede zaak dat er ten minste drie users bestaan met dezelfde user name "username"... Elke iteratie van de while-loop overschrijf je ook effectief $data, dus je ziet alleen de data van het laatste resultaat.
Gewijzigd op 11/09/2019 17:06:21 door Thomas van den Heuvel
de fout melding dat ik heb krijg is alsvolgd
Notice: Undefined variable: data in ..... on line 69
De variabele $data bestaat niet. Waar komt deze vandaan?
- Ariën - op 11/09/2019 17:21:32:
De variabele $data bestaat niet. Waar komt deze vandaan?
dat was vroeger mijn mysql script en werd dat getoond maar sinds kort overgestapt op mysqli en de helfd werkt niet mee kan ik die functie eventueel ergens maken of kan dat niet ?
Edit:
Quotefix
Gewijzigd op 11/09/2019 17:47:58 door - Ariën -
Wat een enorme hoop onzinnige echo's zijn dat! Je zou daar een prachtig blok kant en klare HTML van kunnen maken. Tevens zou het een hele verbetering zijn als je niet halverwege de output nog allerlei queries moet gaan doen. Doe dit voordat je aan je output begint. Kun je altijd nog besluiten om iets anders op het scherm te toveren dan een halve tabel of formulier als er iets mis gaat. Ook is je code dan veel beter leesbaar.
Een beetje editor kan de code wel (re-)identen, zoals dat heet, zodat je een nette structuur hebt.
Een mooi voorbeeldje:
Code (php)
Je ziet zo (ongeveer) precies welke accolade bij welke statement hoort.
In een editor wordt het vaak met lijntjes aangegeven
Gewijzigd op 11/09/2019 17:52:47 door - Ariën -
als ik namelijk even in het script kijk die in eerste instantie is gegeven dan staat daar
Code (php)
1
2
3
4
2
3
4
while ($data = mysqli_fetch_assoc($result)) {
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"gold\">GDI</font></a></td>\n";
echo "<td> </td>\n";
}
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"gold\">GDI</font></a></td>\n";
echo "<td> </td>\n";
}
deze $data staat dus in een while
maar er wordt hierna deze data pas opgevraagd en volgens mij kan dat helemaal niet
omdat het meerdere info kan bevatten
oplossing: het geheel dat je wilt in de while zetten en niet erbuiten
het wordt eigelijk al gezegt in je script
Code (php)
1
//include "functions.php"; eventueel in een functie zetten dat ik $data overal kan gebruiken ?
dus heb ik het even iets aangepast, misschien niet wat je zoekt maar dan snap je het wel :)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
include '../includes/config.php';
echo "<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval('showContent()', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$('.show_content').load('../assets/ajax/timer.php').fadeIn(1000);
}
</script>
<?php
echo "<table width=100% align=\"center\" cellspacing=\"0\" cellPadding=2 border=\"1\" borderColor=\"black\">\n";
echo "<tr><td class=\"subTitle\" align=\"center\"><b>Construction Yard</b></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Click Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Referal Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='username here' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "</table>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>personal Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Click Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Username:</td><td class=\"mainTxt\" width=\"25%\">username</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Clicks</td><td class=\"mainTxt\" width=\"25%\">Total Clicks</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">E-mail:</td><td class=\"mainTxt\" width=\"25%\">email</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Referals</td><td class=\"mainTxt\" width=\"25%\">Total Referals</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Signup IP:</td><td class=\"mainTxt\" width=\"25%\">ip</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Untrained Units</td><td class=\"mainTxt\" width=\"25%\">Total Untrained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Gender:</td><td class=\"mainTxt\" width=\"25%\">gender</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Trained Units:</td><td class=\"mainTxt\" width=\"25%\">Total Trained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
//include "functions.php"; eventueel in een functie zetten dat ik $data overal kan gebruiken ?
$sql = 'SELECT type FROM users WHERE username="username"';
$result = mysqli_query($link, $sql);
while ($data = mysqli_fetch_assoc($result)) {
if (mysqli_num_rows($result) > 2) {
echo '[A]<br>';
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"gold\">GDI</font></a></td>\n";
echo "<td> </td>\n";
}
else
{
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"RED\">NOD</font></a></td>\n";
echo "<td> </td>\n";
}
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><img src=\"" . $data['avatar'] . "\" class=\"img_avatar\" alt=\"Avatar\" /></a></td>\n";
echo "<td> </td>\n";
if ($data['type'] == '1') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/gdi.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
elseif($data['type'] == '2') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/nod.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Building Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>infantrie Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>vehicle Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>air Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>atack Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>defence Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "</ul>\n\n";
echo "</li>\n";
echo "<li class='bar'></li>\n";
echo "</ul>\n\n";
}
mysqli_close($link);
?>
include '../includes/config.php';
echo "<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval('showContent()', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$('.show_content').load('../assets/ajax/timer.php').fadeIn(1000);
}
</script>
<?php
echo "<table width=100% align=\"center\" cellspacing=\"0\" cellPadding=2 border=\"1\" borderColor=\"black\">\n";
echo "<tr><td class=\"subTitle\" align=\"center\"><b>Construction Yard</b></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Click Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "<tr><td class=\"mainTxt\" align=\"center\"><font color=\"silver\">Referal Link: ";
echo "</font><input type=\"text\" value=\"http://www.armiesoftheworld.nl?x='username here' onClick=\"this.focus();this.select();\"></td></tr>\n";
echo "</table>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>personal Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Click Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Username:</td><td class=\"mainTxt\" width=\"25%\">username</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Clicks</td><td class=\"mainTxt\" width=\"25%\">Total Clicks</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">E-mail:</td><td class=\"mainTxt\" width=\"25%\">email</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Referals</td><td class=\"mainTxt\" width=\"25%\">Total Referals</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Signup IP:</td><td class=\"mainTxt\" width=\"25%\">ip</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Untrained Units</td><td class=\"mainTxt\" width=\"25%\">Total Untrained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Gender:</td><td class=\"mainTxt\" width=\"25%\">gender</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">Trained Units:</td><td class=\"mainTxt\" width=\"25%\">Total Trained Units</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
//include "functions.php"; eventueel in een functie zetten dat ik $data overal kan gebruiken ?
$sql = 'SELECT type FROM users WHERE username="username"';
$result = mysqli_query($link, $sql);
while ($data = mysqli_fetch_assoc($result)) {
if (mysqli_num_rows($result) > 2) {
echo '[A]<br>';
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"gold\">GDI</font></a></td>\n";
echo "<td> </td>\n";
}
else
{
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><font color=\"RED\">NOD</font></a></td>\n";
echo "<td> </td>\n";
}
echo "<td class=\"mainTxt\" width=\"25%\">Personal Avatar:</td><td class=\"mainTxt\" width=\"25%\"><img src=\"" . $data['avatar'] . "\" class=\"img_avatar\" alt=\"Avatar\" /></a></td>\n";
echo "<td> </td>\n";
if ($data['type'] == '1') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/gdi.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
elseif($data['type'] == '2') {
$myType2 = "";
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/nod.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>\n";
}
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>Building Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>infantrie Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>vehicle Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>air Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "<br><table width=\"100%\" cellspacing=\"0\" cellPadding=\"2\" border=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>atack Stats</b></td>\n";
echo "<td width=\"10\"> </td>\n";
echo "<td class=\"subTitle\" colspan=\"2\" width=\"50%\"><b>defence Stats</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</a></td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None:</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "<td> </td>\n";
echo "<td class=\"mainTxt\" width=\"25%\">None :</td><td class=\"mainTxt\" width=\"25%\">none</td>\n";
echo "</tr>\n";
echo "</table><br>\n";
echo "</ul>\n\n";
echo "</li>\n";
echo "<li class='bar'></li>\n";
echo "</ul>\n\n";
}
mysqli_close($link);
?>
nu zou hij wel moeten werken
Gewijzigd op 11/09/2019 19:08:17 door sylvester vader
Waarom een while als je toch maar één record terug krijgt?
ik weet dus ook niet wat idee is
maar ik geef alleen even de oplossing in geval het wel meerdere records zijn
Dus... de username moet ook echt username zijn.
Ik neem ten eerste aan dat dit $username moet zijn, of iets in die geest. En verder is een username vrijwel altijd uniek. Dus waarom zou je twee records verwachten? Het klinkt als iets vreemds....
Maar die hele code moet gewoon eerst even goed gereinigd worden.
Gewijzigd op 11/09/2019 19:34:24 door - Ariën -
ik heb even hier en daar iets aangepast
en die echo's allemaal eruit gehaald
ik denk dat Arien zoiets bedoeld
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
include '../includes/config.php';
echo "<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
echo '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval(\'showContent()\', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$(\'.show_content\').load(\'../assets/ajax/timer.php\').fadeIn(1000);
}
</script>';
$username = 'username'; //hier de variable die de username ophaald
$data = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM users WHERE username='$username';"));
echo '
<table width=100% align="center" cellspacing="0" cellPadding=2 border="1" borderColor="black">
<tr>
<td class="subTitle" align="center"><b>Construction Yard</b></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Click Link: </font><input type="text" value="http://www.armiesoftheworld.nl?x=\'\' onClick="this.focus();this.select();"></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Referal Link:</font><input type="text" value="http://www.armiesoftheworld.nl?x='.$data[username].'" onClick="this.focus();this.select();"></td>
</tr>
</table>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>personal Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>Click Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">Username:</td><td class="mainTxt" width="25%">username</a></td>
<td> </td>
<td class="mainTxt" width="25%">Clicks</td><td class="mainTxt" width="25%">Total Clicks</a></td>
</tr>
<tr>
<td class="mainTxt" width="25%">E-mail:</td><td class="mainTxt" width="25%">email</a></td>
<td> </td>
<td class="mainTxt" width="25%">Referals</td><td class="mainTxt" width="25%">Total Referals</a></td>
</tr>
<tr>
<td class="mainTxt" width="25%">Signup IP:</td><td class="mainTxt" width="25%">ip</a></td>
<td> </td>
<td class="mainTxt" width="25%">Untrained Units</td><td class="mainTxt" width="25%">Total Untrained Units</a></td>
</tr>
<tr>
<td class="mainTxt" width="25%">Gender:</td><td class="mainTxt" width="25%">gender</a></td>
<td> </td>
<td class="mainTxt" width="25%">Trained Units:</td><td class="mainTxt" width="25%">Total Trained Units</a></td>
</tr>
<tr>';
if ($data['type'] == '1') {
$myType2 = "";
echo '<td class="mainTxt" width="25%">Personal Avatar:</td><td class="mainTxt" width="25%"><font color="gold">GDI</font><br><img src="' . $data['avatar'] . '" class="img_avatar" alt="Avatar" /></td>
<td> </td>';
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/gdi.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>";
}
else
{
$myType2 = "";
echo '<td class="mainTxt" width="25%">Personal Avatar:</td><td class="mainTxt" width="25%"><font color="RED">NOD</font><br><img src="' . $data['avatar'] . '" class="img_avatar" alt="Avatar" /></td>
<td> </td>
<td class="mainTxt">Type Avatar:</td><td class="mainTxt"><IMG SRC="../assets/images/template/avatars/nod.jpg" WIDTH="45%" HEIGHT="45%" ALT=""></TD>';
}
echo '</tr>
</table>
<br>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>Building Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>infantrie Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
</table>
<br>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>vehicle Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>air Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
<td> </td>\n";
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
</table>
<br>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>atack Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>defence Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
<td> </td>\n";
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
</table>
<br>
<ul>
<li class="bar"></li>
</ul>';
mysqli_close($link);
?>
include '../includes/config.php';
echo "<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
echo '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval(\'showContent()\', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$(\'.show_content\').load(\'../assets/ajax/timer.php\').fadeIn(1000);
}
</script>';
$username = 'username'; //hier de variable die de username ophaald
$data = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM users WHERE username='$username';"));
echo '
<table width=100% align="center" cellspacing="0" cellPadding=2 border="1" borderColor="black">
<tr>
<td class="subTitle" align="center"><b>Construction Yard</b></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Click Link: </font><input type="text" value="http://www.armiesoftheworld.nl?x=\'\' onClick="this.focus();this.select();"></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Referal Link:</font><input type="text" value="http://www.armiesoftheworld.nl?x='.$data[username].'" onClick="this.focus();this.select();"></td>
</tr>
</table>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>personal Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>Click Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">Username:</td><td class="mainTxt" width="25%">username</a></td>
<td> </td>
<td class="mainTxt" width="25%">Clicks</td><td class="mainTxt" width="25%">Total Clicks</a></td>
</tr>
<tr>
<td class="mainTxt" width="25%">E-mail:</td><td class="mainTxt" width="25%">email</a></td>
<td> </td>
<td class="mainTxt" width="25%">Referals</td><td class="mainTxt" width="25%">Total Referals</a></td>
</tr>
<tr>
<td class="mainTxt" width="25%">Signup IP:</td><td class="mainTxt" width="25%">ip</a></td>
<td> </td>
<td class="mainTxt" width="25%">Untrained Units</td><td class="mainTxt" width="25%">Total Untrained Units</a></td>
</tr>
<tr>
<td class="mainTxt" width="25%">Gender:</td><td class="mainTxt" width="25%">gender</a></td>
<td> </td>
<td class="mainTxt" width="25%">Trained Units:</td><td class="mainTxt" width="25%">Total Trained Units</a></td>
</tr>
<tr>';
if ($data['type'] == '1') {
$myType2 = "";
echo '<td class="mainTxt" width="25%">Personal Avatar:</td><td class="mainTxt" width="25%"><font color="gold">GDI</font><br><img src="' . $data['avatar'] . '" class="img_avatar" alt="Avatar" /></td>
<td> </td>';
echo "<td class='mainTxt'>Type Avatar:</td><td class='mainTxt'><IMG SRC='../assets/images/template/avatars/gdi.jpg' WIDTH='45%' HEIGHT='45%' ALT=''></TD>";
}
else
{
$myType2 = "";
echo '<td class="mainTxt" width="25%">Personal Avatar:</td><td class="mainTxt" width="25%"><font color="RED">NOD</font><br><img src="' . $data['avatar'] . '" class="img_avatar" alt="Avatar" /></td>
<td> </td>
<td class="mainTxt">Type Avatar:</td><td class="mainTxt"><IMG SRC="../assets/images/template/avatars/nod.jpg" WIDTH="45%" HEIGHT="45%" ALT=""></TD>';
}
echo '</tr>
</table>
<br>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>Building Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>infantrie Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
</table>
<br>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>vehicle Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>air Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
<td> </td>\n";
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
</table>
<br>
<br>
<table width="100%" cellspacing="0" cellPadding="2" border="0">
<tr>
<td class="subTitle" colspan="2" width="50%"><b>atack Stats</b></td>
<td width="10"> </td>
<td class="subTitle" colspan="2" width="50%"><b>defence Stats</b></td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</a></td>
<td> </td>
<td class="mainTxt" width="25%">None:</td><td class="mainTxt" width="25%">none</td>
</tr>
<tr>
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
<td> </td>\n";
<td class="mainTxt" width="25%">None :</td><td class="mainTxt" width="25%">none</td>
</tr>
</table>
<br>
<ul>
<li class="bar"></li>
</ul>';
mysqli_close($link);
?>
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
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
<?php
include '../includes/config.php';
?>
<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval(\'showContent()\', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$(\'.show_content\').load(\'../assets/ajax/timer.php\').fadeIn(1000);
}
</script>
<?php
$username = 'username'; //hier de variable die de username ophaald
$data = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM users WHERE username='$username';"));
?>
table width=100% align="center" cellspacing="0" cellPadding=2 border="1" borderColor="black">
<tr>
<td class="subTitle" align="center"><b>Construction Yard</b></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Click Link: </font><input type="text" value="http://www.armiesoftheworld.nl?x=\'\' onClick="this.focus();this.select();"></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Referal Link:</font><input type="text" value="http://www.armiesoftheworld.nl?x='.$data[username].'" onClick="this.focus();this.select();"></td>
</tr>
</table>
<!-- etcetera.... -->
include '../includes/config.php';
?>
<link href='../assets/css/game.css' rel='stylesheet' type='text/css' />\n";
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//event used to show content
setInterval(\'showContent()\', 1000);
});
//function for showing content from other file
function showContent()
{
//event to load content from loadContent.php
$(\'.show_content\').load(\'../assets/ajax/timer.php\').fadeIn(1000);
}
</script>
<?php
$username = 'username'; //hier de variable die de username ophaald
$data = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM users WHERE username='$username';"));
?>
table width=100% align="center" cellspacing="0" cellPadding=2 border="1" borderColor="black">
<tr>
<td class="subTitle" align="center"><b>Construction Yard</b></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Click Link: </font><input type="text" value="http://www.armiesoftheworld.nl?x=\'\' onClick="this.focus();this.select();"></td>
</tr>
<tr>
<td class="mainTxt" align="center"><font color="silver">Referal Link:</font><input type="text" value="http://www.armiesoftheworld.nl?x='.$data[username].'" onClick="this.focus();this.select();"></td>
</tr>
</table>
<!-- etcetera.... -->
Of nog beter, zorg dat je eerst de scripts bovenaan uitvoert, vóór je HTML. De voorwaardes kan je prima in je HTML plaatsen.
Of gebruik iets van een templateparser-systeem om de HTML helemaal los te trekken uit je PHP-code.
Gewijzigd op 11/09/2019 22:45:34 door - Ariën -
Impliceert min of meer dat dit allemaal losse PHP-bestanden zijn. Je hebt dus uberhaupt geen single point of entry. Als je grotere applicaties gaat bouwen verdient dat toch echt de voorkeur. Een ander nadeel van het ontbreken van een single point of entry wordt ook direct evident: je zit in verschillende werkdirectories en moet je dus gaan klooien met relatieve paden. Dat is altijd zo'n gehannes (om maar te zwijgen van verwijzingen naar CSS- en JavaScript-bestanden). Ain't nobody got time for that.
Daarbij, een include resulteert niet in een fatal error als het te includen bestand niet gevonden kan worden. Voor de juiste operatie van de rest van de code heb je dit bestand toch echt nodig lijkt mij, dus een require zou eerder op zijn plaats zijn.
Wat dat betreft heeft het niet zoveel zin om deze code te repareren/pimpen, deze moet eerder in zijn totaliteit op de schop. Wat je nu aan het doen bent is toch een beetje equivalent aan een muur sauzen in een huis dat op instorten staat.
Gewijzigd op 12/09/2019 13:40:23 door Thomas van den Heuvel
http://fangorn.thijma.nl/news/redirecting-all-requests-to-index-php-with-htaccess
Op die manier heb je dus een enkele voordeur voor je hele applicatie, waarna je automatisch naar de juiste kamer (pagina) wordt gebracht door een routeringssysteem (ook in deze context router genoemd). Een aanroep naar een los bestand of directory wordt overigens netjes genegeerd.
Het hoeft nog niet eens met fancy URLs maar kan ook simpelweg met een index.php bestand waar je een parameter aan toevoegt: index.php?page=news ofzo. Maar als het geen administratief systeem betreft maar een publieke website is het wel zo mooi als je ook nette, voor mensen leesbare, URLs gebruikt.
Gewijzigd op 12/09/2019 14:49:55 door - Ariën -
Uiteraard, maar als het een administratief systeem is of alles achter een login zit maakt de naamgeving van URLs voor SEO niet zoveel uit.
Inderdaad, die worden ook toch nooit geïndexeerd.
ik vroeg een simple hulp als je nu zegt het is beter in html dat kan zeg me dan ook waarom
ik ben namelijk ook niet zo bekend in php en wat ik zelf had gedaan vroeger wist ik dat alles tussen echo kon zo dat ze dan niet de hele pagina konden rippen ...
een include config lijkt me ook normaal om connectie te maken met je database ...
ik wil inderdaad namelijk zelf proberen om een simpel spelletje te maken maar is meer als 1 .php fille dus lijkt me ook normaal dat ik dat niet in 1 index moet schrijven
Quote:
als je nu zegt het is beter in html dat kan zeg me dan ook waarom
Allereerst: leesbaarheid. Wanneer je in PHP lappen HTML gaat echo'en zul je vroeger of later overal \backslashes\ moeten toevoegen, zoals in bovenstaande code veelvuldig wordt gedaan. Dit vertroebelt de leesbaarheid en maakt code een stuk foutgevoeliger. Daarnaast kun je PHP en HTML beter (zoveel mogelijk) scheiden (ze zijn immers onlosmakelijk met elkaar verbonden) omdat dit het verschil tussen statische (HTML) en dynamische (PHP) content en stuk beter onderscheidbaar maakt.
Quote:
een include config lijkt me ook normaal om connectie te maken met je database
Hm, hier zou ik nog over kunnen uitweiden maar het is in principe goed dat je dit soort functionaliteit scheidt. Het is wel een "verplicht" bestand, deze heb je echt nodig. "include" is wat dat betreft veel vrijblijvender dan een "require". Mocht het bestand niet bestaan dan zal "include" misschien een warning geven, maar de rest van je script loopt dan zeker in de soep. Het is daarom "beter" om echt te eisen dat het bestand aanwezig is, dat doe je met een "require" (of "require_once").
Quote:
dus lijkt me ook normaal dat ik dat niet in 1 index moet schrijven
In dit index.php-bestand zit inderdaad niet alle code van de applicatie maar dit is de kapstok waar je dingen aan ophangt. Stel je hebt nu drie standalone php-bestanden: a.php, b.php en c.php. Die doen allemaal verschillende dingen, maar de opbouw is elke keer hetzelfde. Overal waar je een database nodig hebt include (require :)) je het config.php bestand. En zo maak je met je aardappelstempel nog 20 bestanden aan. En dan op het moment dat er iets in layout of includes wijzigt, dan moet je dat in alle bestanden gaan aanpassen. Dan had je dus beter één index bestand kunnen hebben die de rest van je code opbouwt.