SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Threaded View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    0 Post(s)
    0 Thread(s)

    Anybody willing to help a newbie to PHP?

    I'm gonna jump in here with both feet.

    I've made little "mad libs" type pages using PHP and now I want to take it a baby step further. What I'm trying to do is this:

    I want to set up a page that has a form where the user will enter answers to math problems (I have this page all set up and ready to go) and on submitting the page, it will take you to a page that is set up just like the form, only when their answer is correct, it shows a and if it's wrong it shows a I'd also like the script to keep a tally of how many are correct or how many are incorrect. Now, I'm figuring that to do the first part, my php will have to look like this:
    PHP Code:
    if ("42" == $answer1) { ?>
    <!--<img src="grin.gif">-->
    <?php } else { ?>
    <!--<img src="frown.gif">-->
    <?php ?>
    Now, I'm assuming I'll have to define a variable at the beginning of the script ($correct="0") and somewhere in there have it add 1 for every if statement that shows correct and at the end of the page, use that variable total by having it displayed in the html. How do I have it add one to that total? and where do I put it in relation to each of these if/else statements?

    Moving forward, question 2, am I being at all efficient by putting this into 81 seperate if/else statements? Is there an easier way? Each problem with it's answer will be in a seperate cell of a table, so I don't think it could get easier than this, but I'm not sure.

    I may eventually adapt this to use a database for storing student scores, but that's a whole other kettle of fish.

    I'd appreciate any help y'all can give me.


    Last edited by Susan; Aug 25, 2001 at 10:49.


Posting Permissions

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