Locked lesson.
About this lesson
Addition works, now let's build pages for Subtraction, Multiplication, and Division.
Exercise files
Download this lesson’s related exercise files.
Build Out The Other Math Pages.docx59.4 KB Build Out The Other Math Pages - Solution.docx
59.3 KB
Quick reference
Build out the Other Math Pages
Let's build out the other pages of our app; subtraction, multiplication, and division.
When to use
Time to build out the rest of our app.
Instructions
We can basically copy our addition code and just change all the + signs to the appropriate - * and / signs.
Be sure to change the forms to point to each appropriate page.
Also be sure to add links to the top of each page:
<a href="index.php">Addition</a> | <a href="subtraction.php"></a> | <a href="multiplication.php"></a> | <a href="division.php"></a>
Hints & tips
- Copy the addition code, just change all the signs!
- 00:05 So, our app seems to be working pretty good for addition, so now let's build this
- 00:08 thing out for all the different math functions that we're gonna be doing.
- 00:12 I'm just gonna hit Ctrl + A on my keyboard or cmd + A if you're on a Mac.
- 00:16 Or if you can go up to Edit and actually right-click and click select all,
- 00:20 it does the same thing.
- 00:21 Now I'm gonna hit Ctrl + C copy this cmd + C on a Mac or
- 00:24 you can right click and click Copy.
- 00:26 And I'm just gonna open up the subtraction file here.
- 00:29 Double click it, and I'm just gonna hit Ctrl + V or you can right click and
- 00:33 click Paste, cmd + V on a Mac, and it just pasted in all our math or
- 00:36 all our addition code.
- 00:38 And I am just gonna go through here and type in subtraction for
- 00:41 the headline and I'm gonna look through all the places where there is a plus and
- 00:46 I'm gonna change to minus and so, let's see.
- 00:49 Our correct answer, we need to change that from plus to minus, and
- 00:54 our output minus, all right, I'll put minus there,
- 00:59 okay, I think that's good, so we hit Save, come back here.
- 01:02 And you know what?
- 01:03 We forgot to put links.
- 01:04 So, let's go to the main page again, and just here at the top of the screen,
- 01:10 I'm just gonna create some quick links.
- 01:14 Ok, so for the addition,
- 01:20 it's index.php.
- 01:25 For the subtraction, it's subtraction.php,
- 01:29 multiplication.php and for division,
- 01:33 it's just division.php,and these are just basic html links,
- 01:38 I'll put all this code in the resource file, save this,
- 01:43 come back here, I'm also going to put it here and
- 01:48 actually, let's do a couple of line breaks as well.
- 01:57 Okay, so now if we hit reload, we click on subtraction, 2- 8 is 44.
- 02:05 Wrong, we missed one, 2 + 8.
- 02:07 So let's look at our thing here.
- 02:11 And you know what?
- 02:13 The form action needs to be changed to
- 02:17 subtraction.php 'cause we're sending it to subtraction.
- 02:25 Now if we come back here and hit Reload, 8- 5 is 222, wrong.
- 02:31 8 - 5 = 3, not 222.
- 02:34 3 - 2 is 1, correct, 3 - 2 = 1.
- 02:38 Okay.
- 02:38 So now we are good to go.
- 02:40 We can come back here and copy all of the subtractions stuff.
- 02:43 Open the multiplication.
- 02:48 Likewise, just come through here and change all these to multiplication.
- 02:53 Change this subtraction to
- 02:57 multiplication.php.
- 03:01 Save this back here and hit reload.
- 03:05 Click on multiplication, 2 * 4 is 8.
- 03:07 Submit.
- 03:09 Wrong, 2 * 4 = -2.
- 03:13 Let's see.
- 03:14 What did we miss?
- 03:15 The correct answer, save that.
- 03:19 4 * 3 = 12, correct, 4 * 3 = 12.
- 03:24 Okay, so finally, copy this, save it one more time for the division.
- 03:33 That's just division sign.
- 03:38 Division.
- 03:40 Change that, change that, change that, and change that.
- 03:49 7 / 1 = 7, correct.
- 03:56 So, we are good to go.
- 03:58 Our math flashcard app is fully functioning.
- 04:00 Like I said, you can play around with this, make it look a little nicer.
- 04:03 It's the main functionality I want you to focus on.
- 04:05 And there are lots of ways you can come through here and
- 04:08 make this more elegant, make it less code.
- 04:11 You can make one php file that deals with all of the different things, addition,
- 04:15 subtraction, multiplication and division and
- 04:17 then have each of these just call that one file.
- 04:20 There's lots of different ways that you can do this.
- 04:21 And I recommended that you play around with this.
- 04:23 And just as a way to teach yourself different things, try that.
- 04:26 But kind of fun, pretty easy.
- 04:28 In the next video, we're going to start to talk about templating out our website
Lesson notes are only available for subscribers.