[PHP/SQL] Level up

Gestart doorSebastiaanh7 reacties34 weergaven

8 berichten · pagina 1 van 1

Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
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:

[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
0
Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je de start tijd opslaat. En dan met een ifje het verschil bekijkt?
zoiets als:
if($startijd + $duurtijd = $totaal){}
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ah, ok.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En je vraag?
Niet handig om deze weg te editten.
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, ik heb de startpost verandert naar een andere vraag. Hoop dat iemand mij kan helpen.smile
0
Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat is nu het probleem?
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hij update steeds je xp en zet er dan 1 bij, maar het is al gefixt. smile
0
Janm

Lid

Berichten
6.170
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Sebastiaanh schreef:
Hij update steeds je xp en zet er dan 1 bij, maar het is al gefixt. smile
Kan je misschien de oplossing geven, denk dat ik het misschien nog eens nodig kan hebben smile
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren