Hoi,
Ik heb een functie en die controleert of de gebruiker genoeg XP heeft om level up te gaan, alleen als je nu meer dan 100 XP hebt doet hij elke keer 1 xp erbij, bij elke refresh dus.
Dit is de code:
Mvg,
SebastiaanH
Ik heb een functie en die controleert of de gebruiker genoeg XP heeft om level up te gaan, alleen als je nu meer dan 100 XP hebt doet hij elke keer 1 xp erbij, bij elke refresh dus.
Dit is de code:
[COLOR= #0000BB]<?php
$totXpQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, totaalxp FROM leden WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$totXpFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totXpQuery[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$hXpQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, xp FROM leden WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$hXpFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hXpQuery[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$hLevelQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, level FROM leden WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$hLevelFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hLevelQuery[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totXpFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]totaalxp[/COLOR][COLOR= #007700]] >=[/COLOR] [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$totXpFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]totaalxp[/COLOR][COLOR= #007700]] <[/COLOR] [COLOR= #0000BB]500[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET level = 2, totaalxp = totaalxp+"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hXpFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]xp[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]", xp = 1 WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totXpFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]totaalxp[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]500[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET level = 3, totaalxp = totaalxp+"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hXpFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]xp[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]", xp = 1 WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
}[/COLOR]
?> Mvg,
SebastiaanH
