[php] hulp

Gestart doorFreestyle15 reacties18 weergaven

16 berichten · pagina 1 van 2

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ik heb een script gemaakt en die werkt nu eindelijkyummie
maar ik ben nog niet helemaal te vreden.
het script moet doen: ik voer in de bron code een getal bv, 400
en bij hoeveel ik al heb bv, 250 en dan zegt hij of ik iets wel of niet kan kopen. zo niet hoeveel ik nog moet betalen.

nu geeft hij dit aan:

Helaas je moet nog even wachten

400 - 250 = 150


alleen ik wil hebben:

Helaas je moet nog even wachten

Je moet nog 150euro betalen!


hoe moet ik dat dan doen?

script waar het omgaat:

{
    $prijs = false;
$teller = 400;
$prijs = 250;
echo "<br><BR>"." $teller - $prijs = ". ($teller - $prijs) ."<br>";
}


volledig script:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]>=[/COLOR][COLOR= #0000BB]400[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] true[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"pak je geld maar en hup naar de winkel!"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]>=[/COLOR][COLOR= #0000BB]250[/COLOR][COLOR= #007700]) 
{[/COLOR]
     [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Ga maar snel werken!"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Helaas je moet nog even wachten"[/COLOR][COLOR= #007700];
}

{[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]400[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]250[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br><BR>"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" $teller - $prijs = "[/COLOR][COLOR= #007700]. ([/COLOR][COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$prijs[/COLOR][COLOR= #007700]) .[/COLOR][COLOR= #DD0000]"<br>"[/COLOR][COLOR= #007700];
}[/COLOR]


?>
0
Berichten
1.579
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wel jammer dat je het hier vraag als het goede antwoord gewoon in je boek staat (ja PHP Basiscursus heb ik al...)
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
het antwoord staat niet in het boek hoor!!
en ik doe dit tussen door. met een klein stukje uit het boek (eerste stukje)

dus wie weet hoe het wel moet?
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ps: zie dit niet als dubbel post heb het hele bericht aangepast.
zo bespaar ik dus nog 1 topic!

dus wie kan mij helpen?
0
Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$a = $teller - $prijs;
echo $a;
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
waar moet ik dat dan zetteconfused
0
Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]>=[/COLOR][COLOR= #0000BB]400[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] true[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"pak je geld maar en hup naar de winkel!"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]>=[/COLOR][COLOR= #0000BB]250[/COLOR][COLOR= #007700])
{[/COLOR]
     [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Ga maar snel werken!"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Helaas je moet nog even wachten"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br/>"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"je moet nog "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$hoeveel[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" euro sparen"[/COLOR][COLOR= #007700];
}

{[/COLOR]
[COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]400[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]250[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$hoeveel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$prijs[/COLOR][COLOR= #007700];

}[/COLOR]


?>


probeer dit eens?
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hij zegt:
Helaas je moet nog even wachten
je moet nog euro sparen

dus moet die
$prijs = false;
$teller = 400;
$prijs = 250;
$hoeveel = $teller - $prijs;


niet daar boven komen?

edit///
heb het er boven gezet maar dat doet het nietsadley
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]>=[/COLOR][COLOR= #0000BB]400[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] true[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"pak je geld maar en hup naar de winkel!"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]>=[/COLOR][COLOR= #0000BB]250[/COLOR][COLOR= #007700])
{[/COLOR]
     [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Ga maar snel werken!"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]400[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$prijs[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]250[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$hoeveel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$prijs[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Helaas je moet nog even wachten"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br/>"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"je moet nog "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$hoeveel[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" euro sparen"[/COLOR][COLOR= #007700];
}[/COLOR]


?>


alstu
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
bedankt kenzo.
nu moet ik ff het script anlyseren om er van te lerenyummieyummie
ps: topic mag worden gesloten
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
alstu.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Op deze manier bestaat $prijs niet op het moment dat je checkt of ie groter of gelijk aan 400 is, zelfde geldt voor 250
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
idd, dan is dat gewoon onnodig tenzij je er een query bij maakt en een getal postwink
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ja dat weet ikyummie ik wil dit script ook steeds uitbreiden en verbeterenyummie
ik wil uiteindelijk dat je een getal invoert en hoeveel je hebt. en dat je ook steeds er bij kan invullen hoeveel geld je meer hebt of minder!

maar ik ben php nog aan het leren. dit is mijn eerste echte script die ik zelf heb geschreven!
0
Berichten
10.409
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Freestyle schreef:
ps: zie dit niet als dubbel post heb het hele bericht aangepast.
zo bespaar ik dus nog 1 topic!

dus wie kan mij helpen?
het is we een dubbelpost xd?
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