Help with Code

Hey guys,
So next year im doing an IT ‘‘education’’
And i had to make a program (to show ‘‘us’’ what coding is) that tells what rights these persons have:
Bob 12 years old
Anita 17 years old
Ruben 32 Years old
then the ‘‘rights’’ are at 16 or above you are able to get your motorcycle license, at 18 a car license and when 21 your independant.
They said if i couldnt figure out it was ok to but i really like coding so far.
I already did some tutorials.
But i wanted to know how i can let someone fill in there age and then that the machine uses/detects it. Right now my code is short because i googled and everything how to do this. :

Zadkine Project <?php $age = 16; if ($age >= 16) { echo 'Je mag je Brommer rijbewijs halen!'; } else { echo 'Je mag jammer genoeg NIET je Brommer rijbewijs halen!'; } ?> [/php]

NOTE: The sentances are in Dutch.
Thanks in Advance for the help

I don’t know Dutch, so everything is in English. You got the basics, just need to expand on it.

<?php $age = 16; if ($age == 16) { echo "motorcycle license"; echo 'Je mag je Brommer rijbewijs halen!'; } elseif ($age == 17) { echo "car license"; } elseif($age == 21) { echo "independent"; } else { // this is for when none of the conditions are met echo 'Je mag jammer genoeg NIET je Brommer rijbewijs halen!'; } ?>

That’s probably not the best way of doing it, but since we don’t know where the information is coming from, its hard to tell which you way is the more efficient way of doing it. You could also use a switch or regular if statements.

Thanks, i got it figured out sorta. I joped you could answer 2 more questions for me ( i hope i dont bother you with this to much)
My code right now is:


Zadkine Project <?php $age = 30; if ($age < 19) { echo "Je mag je brommer rijbewijs halen!"; } elseif ($age < 21) { echo "Je mag je brom- en rijbewijs halen!"; } else { echo "Je ben volledig onafhankelijk en mag je brom en rijbewijs halen!"; } ?> [/php] The first question is: It tells if you are younger then 19 that you can get your motorcycle license but that does not count for 15 or younger. But when i try something else for that i get certain errors and problems.

Second question: Is there a way to let people fill in the “$age =” without editing the file?

Thanks in advance!

question 1: that’s because you’re telling it $age = 30, the only condition that’s true is the second one.

question 2: yes, put a simple form in there.

Sponsor our Newsletter | Privacy Policy | Terms of Service