Lecture Notes Fifteen: Starting on the PHP Shopping Cart

Here's the current stage of the shopping cart.

The source code is in three files:

  1. bookstore/index.php (this is the entry point)

  2. bookstore/One.php (a collection of functions)

  3. bookstore/show_cat.php (second screen in application)

There is a database behind it, which only has two tables currently.

burrowww.cs.indiana.edu% mysql -ua348 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3034 to server version: 3.23.27-beta

Type 'help;' or '\h' for help. Type '\c' to clear the buffer

mysql> use a348;
Database changed
mysql> describe dgerman_php_categories;
+---------+------------------+------+-----+---------+-------+---------------------------------+
| Field   | Type             | Null | Key | Default | Extra | Privileges                      |
+---------+------------------+------+-----+---------+-------+---------------------------------+
| catid   | int(10) unsigned |      | PRI | 0       |       | select,insert,update,references |
| catname | char(40)         |      |     |         |       | select,insert,update,references |
+---------+------------------+------+-----+---------+-------+---------------------------------+
2 rows in set (0.00 sec)

mysql> describe dgerman_php_catboo;
+-------+------------------+------+-----+---------+-------+---------------------------------+
| Field | Type             | Null | Key | Default | Extra | Privileges                      |
+-------+------------------+------+-----+---------+-------+---------------------------------+
| isbn  | char(6)          |      | PRI |         |       | select,insert,update,references |
| catid | int(10) unsigned |      | PRI | 0       |       | select,insert,update,references |
+-------+------------------+------+-----+---------+-------+---------------------------------+
2 rows in set (0.00 sec)

mysql> select * from dgerman_php_categories;
+-------+-----------------------------+
| catid | catname                     |
+-------+-----------------------------+
|     1 | Mechanics                   |
|     2 | Typesetting                 |
|     3 | Computers                   |
|     4 | Mathematics                 |
|     5 | Scheme                      |
|     6 | Programming                 |
|     7 | Interpreters                |
|     8 | Compilers                   |
|     9 | Games                       |
|    10 | Number Theory               |
|    11 | Perl                        |
|    12 | Object-oriented programming |
|    13 | Semantics                   |
|    14 | Logic                       |
|    15 | Physics                     |
|    16 | Quantum Physics             |
|    17 | General Physics             |
|    18 | Graduate Math               |
|    19 | Cryptography                |
|    20 | Topology                    |
+-------+-----------------------------+
20 rows in set (0.00 sec)

mysql> select * from dgerman_php_catboo;
+--------+-------+
| isbn   | catid |
+--------+-------+
| fey001 |     1 |
| sus001 |     1 |
| dek003 |     2 |
| dek003 |     3 |
| gkp001 |     3 |
| hpb001 |     3 |
| con002 |     4 |
| dek003 |     4 |
| gkp001 |     4 |
| hpb001 |     4 |
| kob001 |     4 |
| mun001 |     4 |
| fri001 |     5 |
| fri002 |     5 |
| con001 |     6 |
| fri001 |     6 |
| fri002 |     6 |
| hpb001 |     6 |
| fri001 |     7 |
| fri002 |     7 |
| fri001 |     8 |
| con002 |     9 |
| fri002 |     9 |
| con002 |    10 |
| kob001 |    10 |
| con001 |    11 |
| con001 |    12 |
| fri001 |    12 |
| hpb001 |    13 |
| hpb001 |    14 |
| fey001 |    15 |
| pes001 |    15 |
| sus001 |    15 |
| fey001 |    16 |
| pes001 |    16 |
| fey001 |    17 |
| kob001 |    18 |
| mun001 |    18 |
| kob001 |    19 |
| mun001 |    20 |
+--------+-------+
40 rows in set (0.00 sec)

mysql> exit
Bye
burrowww.cs.indiana.edu%
This, with the source code above should be enough to get you started.


Last updated: Oct 16, 2001 by Adrian German for A348/A548