Your own mini-project: plan, build, test, explain
Now do the whole job once for an invented reading club; it needs only paper, and no device. Step 1, the plan: list the pages and the job of each, and draw them as a tree. Step 2, the design: two tables with keys, Members and Loans, one member to many loans, and write two or three sample records with invented nicknames, and no real names or numbers. Step 3, the form for adding a member, with the names of its controls. Step 4, a short valid PHP snippet that uses a variable, an if with elseif and else, and a switch. Step 5, a test table: inputs and the outputs you expect. Step 6, one sentence: the PHP runs on the server, and the browser only receives and shows the HTML that comes out.
| loan_id | member_id | book |
|---|---|---|
| 1 | 1 | Sea Stories |
| 2 | 1 | Star Maps |
| 3 | 2 | Sea Stories |
1<form method="post" action="join_member.php"> 2 <input type="text" name="nick"> 3 <input type="submit" name="join_btn" value="Join"> 4</form>
1<?php 2$day = 6; 3$books = 5; 4if ($books >= 3) { 5 $level = "silver"; 6} else { 7 $level = "new"; 8} 9switch ($day) { 10 case 5: echo "Meeting"; break; 11 case 6: echo "Book swap"; break; 12 default: echo "Closed"; 13} 14echo " - ", $level; 15?>
Book swap - silver
| day | books | expected output |
|---|---|---|
| 6 | 5 | Book swap - silver |
| 5 | 1 | Meeting - new |
| 2 | 3 | Closed - silver |
Do all six steps on a sheet of paper for a club of your own invention (a chess club, a garden club...). Check at the end that your PHP lines end with semicolons, that each switch case ends with break, that no real person appears in the sample records, and that your test table has at least three rows.