Review: web pages, servers and planning a site
This week we look back over Units 1 to 3, using new tasks and not the questions of the book. Start with sorting. A page that shows the same text to everybody is static; a page that PHP builds from the Terms table is dynamic and must be asked from a server that can run PHP. Work you do on your own computer with a local server is localhost; a site that visitors reach from other places is on hosting. A free program costs nothing, and an open source program also lets you read and change its code. Then the tables: each record is one row, each field is one column, and the primary key (remember: different in every record) names the record. When two tables are linked, the foreign key sits on the “many” side. For one club with many loans, the Loans table keeps the member number. Last, remember that 1 KB is 1,024 bytes, so a file of 2,048 bytes is 2 KB.
| Situation | Static or dynamic? | Needs PHP? |
|---|---|---|
| a Help page with fixed text | static | no |
| a list of terms read from the table | dynamic | yes |
| a page that shows today’s date | dynamic | yes |
| a page of club rules that never changes | static | no |
1CREATE TABLE Members (member_id INT NOT NULL PRIMARY KEY, nick VARCHAR(30) NOT NULL, level VARCHAR(10)); 2CREATE TABLE Loans (loan_id INT NOT NULL PRIMARY KEY, member_id INT NOT NULL, book VARCHAR(50) NOT NULL, FOREIGN KEY (member_id) REFERENCES Members(member_id));
1SELECT Term FROM Terms WHERE id > 1;Term cable browser
1DELETE FROM Terms WHERE id = 1;1 row affected
On paper sort these eight items into two lists, “runs on the server” and “runs in the browser”: PHP code; a JavaScript check of an empty box; an SQL INSERT; showing the finished HTML page; the include of header.php; choosing a picture file in the form; a query on the Terms table; the page title in the title bar. Then say what kind of key id is in the Terms table. Add one sentence: which table of a club has the foreign key, Members or Loans, and why?