A simple question
Posted: Wed Apr 02, 2008 1:22 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi all ! I have a website for helping south american people to learn english for free. I've been trying to work out a simple script, it should just store about 20 words and their spanish translation. Eg:
red = rojo
green = verde
etc
Then, the visitor types their answer into a text box, and it goes to the next word, until the end when it tells them - you got 14 / 20 right etc
Well I have absolutely no skills.. so after a lot of asking, I finally found someone to make something for me:
But now they have dissapeared and I have no idea what to do next. Obviously I understand this $word[1] = 'green'; part, I can just duplicate that to make more.. but apart from that, what do I actually do with this? I tried to just copy and paste it into my website code but nothing much happened. Imagine you are talking to an alien who has never seen PHP before, if anyone can help me, thankyou!!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi all ! I have a website for helping south american people to learn english for free. I've been trying to work out a simple script, it should just store about 20 words and their spanish translation. Eg:
red = rojo
green = verde
etc
Then, the visitor types their answer into a text box, and it goes to the next word, until the end when it tells them - you got 14 / 20 right etc
Well I have absolutely no skills.. so after a lot of asking, I finally found someone to make something for me:
Code: Select all
<?php
// Start by putting some variables that I'll edit.
$correctcount = 0; // The correct count.
$wrongcount = 0; // The correct count.
$string = 'What the user typed'; // what the user put.
$word[0] = 'red'; $answer[0] = 'rojo'; $returned_answer[0] = 'What they put'; // Words, with answers
$word[1] = 'green'; $answer[1] = 'verde'; $returned_answer[1] = 'What they put';
foreach($word as $key => $value){ // Go through questions and compare answers.
if($returned_answer[$key] == $answer[$key]){
echo "Correct! $value is the same as: $answer[$key]";
$correctcount = $correctcount + 1; // Add to correct counts.
} else {
echo "Wrong :( $value is not: $returned_answer[$key], it is $answer[$key]";
$wrongcount = $wrongcount + 1;// Add to wrong counts.
}
}
echo "You got $correctcount out of ".$correctcount+$wrongcount; // Say the score.
?>~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: