kakes Posted January 14, 2011 Share Posted January 14, 2011 I need to create a php page that displays a random mulitplication flashcard with answer. The background needs to be black and the font white. There needs to be an answer area with a font color of black. The page has to include instruction to the user on how to check their answer - highlight the area to the right of the equals sign. I'm supposed to useĀ $value=rand(1,12). The two numbers that are to be multiplied are 8x12, the answer of course is 96. I've read all I can find on this and still don't understand what to do. Please help! Quote Link to comment Share on other sites More sharing options...
btherl Posted January 14, 2011 Share Posted January 14, 2011 Can you post your code so far? Quote Link to comment Share on other sites More sharing options...
kakes Posted January 14, 2011 Author Share Posted January 14, 2011 Sure. Thanks for replying. This is what I have so far. You'll see that I am completely lost. Ā // Variables Ā $title="Assignment 1" // variable to display title Ā Ā echo "<html> Ā Ā Ā <head> Ā Ā Ā Ā <title> Ā Ā Ā Ā $title Ā Ā Ā Ā </title> Ā Ā Ā </head> Ā <body style=\"background-color:black\">Ā Ā Ā Ā Ā </body>Ā Ā </html>"; Ā Ā Ā ?> Ā Ā Ā Quote Link to comment Share on other sites More sharing options...
btherl Posted January 14, 2011 Share Posted January 14, 2011 I think what you need is a basic tutorial for php.Ā The first person you should be asking is your teacher or tutor.Ā If you can't ask them for some reason, you can look for "php tutorial" in google and you will find several tutorials.Ā You might need to look at a few before you find one that matches your learning style. Ā I can't really help you here until you've gotten the basics. Quote Link to comment Share on other sites More sharing options...
kakes Posted January 15, 2011 Author Share Posted January 15, 2011 Okay, I've been working on this and seem to be getting how it works, somewhat. I just can't seem to figure out how I'm going to get the background black, the text white, and the multiplication answer to display in black text and only be visable when you highlight it. Any suggestions? Ā Ā echo "<html> Ā Ā Ā <head> Ā Ā Ā Ā <title> Ā Ā Ā Ā $title Ā Ā Ā Ā </title> Ā Ā Ā </head> Ā <body>\n"; Ā Ā echo "<h3>Instructions: To check your answer, highlight the area to the right of the equals mark.</h3>\n"; Ā echo "<h1>8x12="."$multiplication</h1>\n"; Ā Ā Ā Ā echo "</body>\n</html>" Ā Ā Ā ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 15, 2011 Share Posted January 15, 2011 Well that may obscure it when the browser renders it, but it will still be clearly visible in a View --> Source, which would defeat the purpose, wouldn't it? This really should get a topic of its own, BTW. Ā Simple variables can be place directly into a double-quoted string; no concatenation necessary . . . echo "<h1>8x12=$multiplication</h1>\n"; Ā Quote Link to comment Share on other sites More sharing options...
btherl Posted January 16, 2011 Share Posted January 16, 2011 I don't think it's a problem for it to be visible in the source, pikachu.Ā kakes, don't you have course notes saying how to change font colour?Ā It can be done with an HTML font tag, or with CSS. Quote Link to comment Share on other sites More sharing options...
kakes Posted January 16, 2011 Author Share Posted January 16, 2011 I've tried putting the html code in the body tag to change the font and background color, but it doesn't work. I guess I'm missing something...maybe a semi colon or something. Ā Thanks for any suggestions. Ā Ā echo "<html> Ā Ā Ā <head> Ā Ā Ā Ā <title> Ā Ā Ā Ā $title Ā Ā Ā Ā </title> Ā Ā Ā </head> Ā <body style=\"background-color:black\font color:white">\n"; Ā Ā echo "<h3>Instructions: To check your answer, highlight the area to the right of the equals mark.</h3>\n"; Ā echo "<h1>8x12="."$multiplication</h1>\n"; Ā Ā Ā Ā echo "</body>\n</html>" Ā Ā Ā ?> Ā Ā Ā Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 16, 2011 Share Posted January 16, 2011 Your syntax was wrong in this line: <body style=\"background-color:black;color:white;\">\n"; Quote Link to comment Share on other sites More sharing options...
kakes Posted January 16, 2011 Author Share Posted January 16, 2011 Thanks! So appreciated! Now, how do I get the answer to display in black and only be visable when you highlight it? I think I would need to somehow write it into the variable but maybe it needs to be in the code line...not sure. I'll work on it but will appreciate any suggestions. Quote Link to comment Share on other sites More sharing options...
kakes Posted January 18, 2011 Author Share Posted January 18, 2011 I've got a new problem. I have to use rand() to generate the random multiplication. I've been trying everything, watching tutorials, reading my text, another reference book that I bought, still don't have what I need. This code is a mess but it's all I could come up with. You'll see how crazy I've become! Thanks. Ā /Variables Ā $title = Assignment1; // variable to display title Ā $value1 = rand(1,12); // first number as a variable Ā $value2 = rand(1,12); // second number as a variable Ā $total = rand(1,12); // total of the two numbers as a variable Ā Ā echo "<html> Ā Ā Ā <head> Ā Ā Ā Ā <title> Ā Ā Ā Ā $title Ā Ā Ā Ā </title> Ā Ā Ā </head> Ā <body style=\"background-color:black;color:white;\">\n"; Ā Ā echo "<h3>Instructions: To check your answer, highlight the area to the right of the equals mark.</h3>\n"; Ā echo "<h1>($value1*$value2)=$total</h1>\n"; Ā Ā Ā Ā echo "</body>\n</html>" Ā Ā Ā ?> Ā Help... Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 You really aren't that far off. Ā $total = rand(1,12); would have to accidentally generate the correct total. To get the right number, you'd need to find the product of the randomly generated multiplicand ($value1) and multiplier ($value2). Ā $total = $value1 * $value2; Ā Then, you just need to tweak the way you echo the values so the values are echoed with the correct total, and add the color to the answer. If you have any questions about what I changed or why, just say so. Ā <?php $title = Assignment1; // variable to display title Ā $value1 = rand(1,12); // first number as a variable Ā $value2 = rand(1,12); // second number as a variable Ā $total = $value1 * $value2; // total of the two numbers as a variable Ā echo "<html> Ā Ā Ā <head> Ā Ā Ā Ā <title> Ā Ā Ā Ā $title Ā Ā Ā Ā </title> Ā Ā Ā </head> Ā <body style=\"background-color:black;color:white;\">\n"; Ā echo "<h3>Instructions: To check your answer, highlight the area to the right of the equals mark.</h3>\n"; Ā Ā echo "<h1>$value1 * $value2Ā = <font color=\"black\">$totalĀ </font></h1>\n"; Ā echo "</body>\n</html>" Ā Ā Ā ?> Ā EDIT: Simplified the echo a bit . . . Quote Link to comment Share on other sites More sharing options...
kakes Posted January 19, 2011 Author Share Posted January 19, 2011 You just don't know how thankful I am that you took the time to help with this. I was at my wit's end. After you explained about the variables and how I had done the echo, it was so much clearer. I wasn't thinking it through, I suppose. Glad to hear I was at least close to getting it. I just needed a little push. Thanks again!! It worked like a charm!! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 19, 2011 Share Posted January 19, 2011 Glad I was able to help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.