▶ TrainingGet Pro
All tools & lessonsAll toolsAllGet the appApp
Learning departments Music, Math, Cookery, Programming and Art are open – explore →

PHP lesson 24: Project: a results page

US version. US grades and US spelling. · UK 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 (Grades 9–12), from Unit 8: Algorithms and a project. It runs right here in your browser – nothing to install.

Time
50 minutes + 40 min homework
Grade
Grades 9–12 (ages 14–18)
You need
A computer or tablet, paper and a pencil
Graded
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 – graded 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.

  1. Read what your child will learn together.
  2. 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.
  3. 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.
  4. 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

Learning goal: 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

50 minutes in 5 parts
PartTimeHow it is checked
Starter5 minGraded by Classfern
Teaching input8 minRead, watch and talk
See it, then predict8 minGraded by Classfern
Put it in order, trace it, check it22 minGraded by Classfern + teacher or parent, with our checklist
Closure and exit ticket7 minGraded by Classfern + self-check

Checklist for the project (teacher or parent)

The questions in this lesson are graded by Classfern. The results page your child makes at the end is judged by you, with this checklist – it is not graded 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 graded instantly.

Write it and fix it: practice tests

The practice tests run real PHP in your browser: write and fix short programs, graded against hidden tests.

All PHP practice tests · All 24 PHP lessons

Curriculum

CSTA K–12 Computer Science Standards (2017): 3B-AP-17 – Plan and develop programs for broad audiences using a software life cycle; 3B-AP-14 – Build solutions from student-created procedures, modules or objects.

The standard codes are CSTA's; the descriptions are our own words.

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.