Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: Need some help!

  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Need some help!

    Alright im new to PHP and MySQL but i heard from a friend that in order to do what im thinking of i'll have to learn it. But i was just wondering if any of you guys could help me even further. I read w3schools.net info and have a basic understanding

    This is what i want to do:

    I want to be able to create a Question and Answer Page like a Quiz.

    I want something like this:
    Question: What's my name?
    Answer:______________

    I don't want multiple choice but instead i want it to where the user has to write it.

    Could you guys help?

    Quote Originally Posted by litoburrito View Post
    I want them to be able to answer one at a time.
    If they get it right they move on.
    If they don't they stay there.
    But then i also want them to not be able to do the quiz more than once
    so if they complete it all they can't do it again.
    Last edited by litoburrito; 01-07-2010 at 01:13 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Do they answer one question at a time, and get a correct or not,
    or do they answer a whole page of them and then submit it?

    It sort of makes a big difference.

  • Users who have thanked mlseim for this post:

    litoburrito (01-07-2010)

  • #3
    New Coder
    Join Date
    Jan 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I want them to be able to answer one at a time.
    If they get it right they move on.
    If they don't they stay there.
    But then i also want them to not be able to do the quiz more than once
    so if they complete it all they can't do it again.

  • #4
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts
    You'd probably need a register each user who takes your Quiz, give them a username and password.

    Then for each question, you'd want to either store them in a Database or text file and use PHP to grab the results. Use a html form to allow the user to submit their answer and check it against the right one, if correct, move them on, if not re-show the question.

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You should use AJAX to put the PHP together with Javascripting so
    the answers that are wrong, stay on the same page without refreshing.
    A little bit more interactive and a cleaner user interface.

    Best yet would be to use Flash with an XML file for the questions/answers.

    There are so many different approaches to this one ... not sure what
    direction you want to go, and how nice you want it to look and operate.
    You can make it simple and clunky, or smooth and a good user experience.

    I guess you decide how important the site will be, and the effort you want to use.

  • #6
    New Coder
    Join Date
    Jan 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I want to be able to customize it to look real nice but i guess i could just add an image behind it and stuff but right now i just want to be able to make it happen.

    I have a vbulletin so that pretty much has the user info.

    But i don't have flash or nothing like that. I'm pretty much gonna try and do it by using Notepad haha.

    Could you tell me what i would possible need to learn and what i would have to use.

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You don't really need MySQL for your questions/answers, make it simple by using a plain text file.

    Make a file called "quiz.txt" that has a number|question|answer on each line separated by pipes |

    1|What is the capital of Minnesota?|St. Paul
    2|What is the capital of Wisconsin?|Madison

    etc.

    But you can see there's a problem already ...
    What if I answer #1 like this: saint paul

    How accurate do the answers need to be?
    Do they have to be case-sensitive?
    Might there be more than one correct answer?

    You once again have a couple directions you could go ...

    Add a bunch of alternate answers ...
    1|What is the capital of Minnesota?|St. Paul|saint paul|sant paul|st. pal|saint pal|

    Or, you could use a PHP command that "weighs" how close the answer is...
    http://php.net/manual/en/function.similar-text.php

    So, figure out what to do now ....

  • #8
    New Coder
    Join Date
    Jan 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well i would want it to figure out the relative
    like i think that php thing is right so if i used that it would make
    st. acceptable for saint?
    Their would be one right answer.
    Now how would i connect that to show correctly?

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Well, first make a text file with all of the questions ... like this:

    1|What is the capital of Minnesota?|St. Paul
    2|What is the capital of Wisconsin?|Madison

    Then, attach that .txt file to a post so we can see it.

    The first step is to display the questions and check the answer.

    Once it all works, you'll be dealing with the "user login" issue,
    but that is something for later on.

  • #10
    New Coder
    Join Date
    Jan 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Alrite so here is just some questions i thought up of right now haha
    Attached Files Attached Files

  • #11
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Maybe like this.....:

    PHP Code:

    <form>
    Whos the owner of Disneyland?
    <input type="text" name="answer" />
    </form> 

    <?php

    $answer 
    $_POST['answer'];

    if (
    $answer == 'Walt Disney') {

    echo 
    "That was correct!";
    echo 
    "<p><a href=\"question2.php\">Go to the next question...</a>";  // sorry, forgot the last ' " '

    }
    ELSE {

    echo 
    "wrong! Try again";

    }

    ?>
    Last edited by fail; 01-07-2010 at 03:22 AM.

  • #12
    New Coder
    Join Date
    Jan 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    But how would i put my text file in there?
    I would have to right all the questions in there?

    Your code didn't work i got this


    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/legsmith/public_html/burritos/hi.php on line 22
    Last edited by litoburrito; 01-07-2010 at 03:13 AM.

  • #13
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I forgot one ' " ' - see above where....

  • #14
    New Coder
    Join Date
    Jan 2010
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    That didn't work
    but would that code do what i've been wanting?

    I don't really want it to go to another page cuz i don't want to have all these pages.
    Does it allow you to go back and redo the whole quiz?

  • #15
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by fail View Post
    Maybe like this.....:
    No, not like that at all. That's hard-coded - it doesn't take advantage of the text file.

    litoburrito, stick with mlseim. He knows what he's doing. He'll probably be back and point you towards fopen and related functions, or perhaps file_get_contents. Do some reading on php file handling while you're waiting for him.
    Are you a Help Vampire?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •