PHP lesson 24: Project: a results page
UK version. UK school years and UK spelling. · US version of this lesson
Your project: a **results page**. It takes a list of names and scores, works out each grade with a function, and prints an HTML table. A ?sort= value from the form chooses the order. A complete 50-minute PHP lesson (Years 10–11, KS4), from Unit 8: Algorithms and a project. It runs right here in your browser – nothing to install.
- Time
- 50 minutes + 40 min homework
- Year
- Years 10–11, KS4 (ages 14–18)
- You need
- A computer or tablet, paper and a pencil
- Marked
- Mostly instantly; the project with our checklist
For parents: how to use this lesson
You don't need to know PHP yourself. The lesson explains each step on screen, the way Mr Babbage, our Head of Computing, likes it: a worked example first, then a go for your child. Your child predicts what code prints, traces it and puts it in order – marked straight away – and then writes and fixes real PHP in the practice test, where it runs in the browser. The results page they make at the end is judged by you, with our checklist below.
- Read what your child will learn together.
- Press Start the lesson below. Sit with your child for the teaching and the worked example (about 16 minutes): ask them to say what each line does.
- Let them do the practice on their own, then the write-it and fix-it questions in the practice test. When code goes wrong, PHP's message is a clue – let them read it out and try again before you help.
- Finish with the talk question: What would you add next to your results page, and how would you test it?
Watch out for
- Testing once is enough. Test missing and unusual input too.
- A project is finished when it runs. It is finished when it is tested, clear and safe.
Miss Lovelace's tip for home: ask your child to explain one line of their program to you in their own words. If they can explain it, they understand it – and every message from PHP is a clue, not a failure.
What your child will learn
We are learning to plan a small PHP page that turns data into HTML.
Success looks like
- I can plan a small PHP page that turns data into HTML.
- I can use arrays, a loop, a function and form data together.
- I can test it with normal, missing and harmful input.
Key words
project · plan · test plan · edge case · user · evaluation
What to have ready
- A device with a web browser (PHP runs in the browser – nothing to install)
- Paper for tracing
- A keyboard helps for typing code (a tablet or phone works too)
The big ideas (for the adult)
Your project: a **results page**. It takes a list of names and scores, works out each grade with a function, and prints an HTML table. A ?sort= value from the form chooses the order.
Plan first: what data, which function, what HTML? Build one part at a time and run it often. Test with normal data, with a missing form value and with a name like <b>Bo</b>.
When it works, make it clear: good variable names, comments, and htmlspecialchars() on everything from outside. Your teacher or parent will judge the finished page with our checklist.
Worked example – see it
<?php
$scores = ["Maya" => 24, "Raj" => 73, "Leo" => 21];
$total = 0;
foreach ($scores as $s) {
$total += $s;
}
echo round($total / count($scores), 1);It prints:
39.3
The lesson, step by step
| Part | Time | How it is checked |
|---|---|---|
| Starter | 5 min | Marked by Classfern |
| Teaching input | 8 min | Read, watch and talk |
| See it, then predict | 8 min | Marked by Classfern |
| Put it in order, trace it, check it | 22 min | Marked by Classfern + teacher or parent, with our checklist |
| Plenary and exit ticket | 7 min | Marked by Classfern + self-check |
Checklist for the project (teacher or parent)
The questions in this lesson are marked by Classfern. The results page your child makes at the end is judged by you, with this checklist – it is not marked by computer. For each line, choose the description that fits best.
- Planning: the data, the function and the HTML were planned before coding
No plan → Some parts planned → A clear plan that was followed - It works: the results table and grades are right for the data
Does not run → Runs, with some mistakes → Right for normal data → Right, even for missing or unusual form values - Safe: every value from outside is checked and printed with htmlspecialchars()
Not safe → Some values made safe → Every outside value checked and made safe - Readable: clear names, helpful comments and tidy HTML output
Hard to follow → Mostly clear → Clear names, comments and tidy output throughout
The lesson
It runs here on the page. No sign-up and no names – progress is kept only in this browser. Each visit picks a new mix of questions.
Homework
40 minutes: 5 questions – predict what code prints, trace it or put it in order, and check the key ideas – then a short reflection, and finishing the results page. New questions every time, all marked instantly.
Write it and fix it: practice tests
The practice tests run real PHP in your browser: write and fix short programs, marked against hidden tests.
Curriculum
National curriculum in England, computing, key stage 4: pupils should be taught to develop their capability, creativity and knowledge in computer science, digital media and information technology; and to develop and apply their analytic, problem-solving, design, and computational thinking skills.
Contains public sector information licensed under the Open Government Licence v3.0.
Our lessons and questions are our own. They are not written or endorsed by any government department, testing agency or exam board. Classfern is not affiliated with or endorsed by The PHP Group. PHP runs here as php-wasm, under its open-source licences.