Help mn Ster Admin!
De code haalt de gegevens goed op uit de database, maar als de gegevens zijn veranderd en er op Veranderen word geklikt, worden de gegevens niet geupdate wat wel de bedoeling hoort te zijn.
Zal iemand kunnen helpen door te zeggen welk stuk in de code veranderd moet worden?
hieronder de code
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
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
<?php
session_start();
include_once ("config.php");
mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ('Kan niet connecten!');
mysql_select_db($dbname) or die ('Kan de database niet selecteren!');
if(isset($_POST['verander'])) {
mysql_query("
UPDATE test_users
SET user_stars = '" . $_POST['user_stars'] . "',
user_warnings = '" . $_POST['user_warnings'] . "'
") or die (mysql_error());
?>
<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
<th class="thHead"><b>Informatie</b></th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="1" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td align="center">
<span class="gen">De sterren en waarschuwingen zijn veranderd<br /><br />
Klik <a href="sterrenveranderen.php">hier</a> om nog iets te veranderen</span>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
<?php }
else
{ ?>
<form action="<?=$_SERVER['REQUEST_URI'];?>" method="post">
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<tr>
<th class="thHead" colspan="5"><b>Regel Veranderen</b></th>
</tr>
<?php
$resultaat = mysql_query("
SELECT user_id, username, user_rank, user_stars, user_warnings
FROM test_users
ORDER BY user_rank DESC") or die(mysql_error());
while ($row = mysql_fetch_assoc($resultaat)) {
?>
<tr>
<td class="row1">
<span class="gen"><b><?=$row['username'];?></b></span>
</td>
<td class="row1">
<span class="gen"><b>Waarschuwingen</b></span>
</td>
<td class="row2">
<span class="gen"><select name="user_warnings">
<?php
for($i = 0; $i <= 5; $i++) {
if($i == $row['user_warnings']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
} else {
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span>
</td>
<td class="row1"><span class="gen"><b>Sterren</b></span></td>
<td class="row2">
<span class="gen"><select name="user_stars">
<?php
for($i = 0; $i <= 999; $i++) {
if($i == $row['user_stars']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
} else {
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span> </td>
</tr>
<?php
}
?>
<tr>
<td class="catBottom" colspan="2" align="center" height="28">
<input type="submit" name="verander" value="Verzenden"></td>
</tr>
</table>
</form>
<?php
}
?>
session_start();
include_once ("config.php");
mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ('Kan niet connecten!');
mysql_select_db($dbname) or die ('Kan de database niet selecteren!');
if(isset($_POST['verander'])) {
mysql_query("
UPDATE test_users
SET user_stars = '" . $_POST['user_stars'] . "',
user_warnings = '" . $_POST['user_warnings'] . "'
") or die (mysql_error());
?>
<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
<th class="thHead"><b>Informatie</b></th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="1" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td align="center">
<span class="gen">De sterren en waarschuwingen zijn veranderd<br /><br />
Klik <a href="sterrenveranderen.php">hier</a> om nog iets te veranderen</span>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
<?php }
else
{ ?>
<form action="<?=$_SERVER['REQUEST_URI'];?>" method="post">
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<tr>
<th class="thHead" colspan="5"><b>Regel Veranderen</b></th>
</tr>
<?php
$resultaat = mysql_query("
SELECT user_id, username, user_rank, user_stars, user_warnings
FROM test_users
ORDER BY user_rank DESC") or die(mysql_error());
while ($row = mysql_fetch_assoc($resultaat)) {
?>
<tr>
<td class="row1">
<span class="gen"><b><?=$row['username'];?></b></span>
</td>
<td class="row1">
<span class="gen"><b>Waarschuwingen</b></span>
</td>
<td class="row2">
<span class="gen"><select name="user_warnings">
<?php
for($i = 0; $i <= 5; $i++) {
if($i == $row['user_warnings']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
} else {
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span>
</td>
<td class="row1"><span class="gen"><b>Sterren</b></span></td>
<td class="row2">
<span class="gen"><select name="user_stars">
<?php
for($i = 0; $i <= 999; $i++) {
if($i == $row['user_stars']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
} else {
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span> </td>
</tr>
<?php
}
?>
<tr>
<td class="catBottom" colspan="2" align="center" height="28">
<input type="submit" name="verander" value="Verzenden"></td>
</tr>
</table>
</form>
<?php
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Clown
zo hij is geëdit
mysql_query("
UPDATE test_users
SET user_stars = '" . $_POST['user_stars'] . "',
user_warnings = '" . $_POST['user_warnings'] . "'
") or die (mysql_error());
maar hoe moet MySQL weten welke user je bedoelt? Er staat geen WHERE condition in je query (dus bv iets als: WHERE user_id = 2).
dus ik heb hier een hidden met ID toegevoegd en een WHERE maar het werkt zo niet (iig niet bij PHP4)
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
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
<?php
session_start();
include_once ("config.php");
mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ('Kan niet connecten!');
mysql_select_db($dbname) or die ('Kan de database niet selecteren!');
?>
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td align="left" valign="bottom"><span class="nav"><a href="adminhome.php" class="nav">Beheerderspaneel openen</a></span></td>
</tr>
</table>
<?php
if(isset($_POST['verander'])) {
mysql_query("
UPDATE test_users
SET user_stars = '" . $_POST['user_stars'] . "',
user_warnings = '" . $_POST['user_warnings'] . "'
WHERE user_id = " . $_POST['user_id']) or die (mysql_error());
?>
<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
<th class="thHead"><b>Informatie</b></th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="1" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td align="center">
<span class="gen">
De sterren en waarschuwingen zijn veranderd<br /><br />
Klik <a href="adminhome.php">hier</a> om naar het Beheerderspaneel te gaan<br /><br />
Klik <a href="sterrenveranderen.php">hier</a> om een nieuwe regel te plaatsen
</span>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
else
{
?>
<form action="<?=$_SERVER['REQUEST_URI'];?>" method="post">
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<tr>
<th class="thHead" colspan="5"><b>Regel Veranderen</b></th>
</tr>
<?php
$resultaat = mysql_query("
SELECT user_id, username, user_rank, user_stars, user_warnings
FROM test_users
ORDER BY user_rank DESC") or die(mysql_error());
while ($row = mysql_fetch_assoc($resultaat)) {
?>
<tr>
<td class="row1"><span class="gen"><b><?=$row['username'];?></b>
<input type="hidden" name="user_id" value="<?=$row['user_id'];?>"></span></td>
<td class="row1"><span class="gen"><b>Waarschuwingen</b></span></td>
<td class="row2"><span class="gen"><select name="user_warnings">
<?php
for($i = 0; $i <= 5; $i++) {
if($i == $row['user_warnings']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
}
else
{
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span></td>
<td class="row1"><span class="gen"><b>Sterren</b></span></td>
<td class="row2"> <span class="gen"><select name="user_stars">
<?php
for($i = 0; $i <= 999; $i++) {
if($i == $row['user_stars']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
}
else
{
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span> </td>
</tr>
<?php
}
?>
<tr>
<td class="catBottom" colspan="2" align="center" height="28">
<input type="submit" name="verander" value="Verzenden">
</td>
</tr>
</table>
</form>
<?php
}
?>
session_start();
include_once ("config.php");
mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ('Kan niet connecten!');
mysql_select_db($dbname) or die ('Kan de database niet selecteren!');
?>
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td align="left" valign="bottom"><span class="nav"><a href="adminhome.php" class="nav">Beheerderspaneel openen</a></span></td>
</tr>
</table>
<?php
if(isset($_POST['verander'])) {
mysql_query("
UPDATE test_users
SET user_stars = '" . $_POST['user_stars'] . "',
user_warnings = '" . $_POST['user_warnings'] . "'
WHERE user_id = " . $_POST['user_id']) or die (mysql_error());
?>
<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
<th class="thHead"><b>Informatie</b></th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="1" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td align="center">
<span class="gen">
De sterren en waarschuwingen zijn veranderd<br /><br />
Klik <a href="adminhome.php">hier</a> om naar het Beheerderspaneel te gaan<br /><br />
Klik <a href="sterrenveranderen.php">hier</a> om een nieuwe regel te plaatsen
</span>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
else
{
?>
<form action="<?=$_SERVER['REQUEST_URI'];?>" method="post">
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<tr>
<th class="thHead" colspan="5"><b>Regel Veranderen</b></th>
</tr>
<?php
$resultaat = mysql_query("
SELECT user_id, username, user_rank, user_stars, user_warnings
FROM test_users
ORDER BY user_rank DESC") or die(mysql_error());
while ($row = mysql_fetch_assoc($resultaat)) {
?>
<tr>
<td class="row1"><span class="gen"><b><?=$row['username'];?></b>
<input type="hidden" name="user_id" value="<?=$row['user_id'];?>"></span></td>
<td class="row1"><span class="gen"><b>Waarschuwingen</b></span></td>
<td class="row2"><span class="gen"><select name="user_warnings">
<?php
for($i = 0; $i <= 5; $i++) {
if($i == $row['user_warnings']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
}
else
{
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span></td>
<td class="row1"><span class="gen"><b>Sterren</b></span></td>
<td class="row2"> <span class="gen"><select name="user_stars">
<?php
for($i = 0; $i <= 999; $i++) {
if($i == $row['user_stars']) {
?>
<option value="<?=$i;?>" selected="selected"><?=$i;?></option>
<?php
}
else
{
?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php
}
}
?>
</select></span> </td>
</tr>
<?php
}
?>
<tr>
<td class="catBottom" colspan="2" align="center" height="28">
<input type="submit" name="verander" value="Verzenden">
</td>
</tr>
</table>
</form>
<?php
}
?>
Gewijzigd op 01/01/1970 01:00:00 door clown