Prev | Current Page 201 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

As
pointed out earlier, you can find the SQL scripts in the book??™s code in the Source Code/Download section of the
Apress web site (http://www.apress.com). Figure 5-5 shows data from the category table as shown by
phpMyAdmin.
Figure 5-5. Data from the category table
In the SQL code, note how we escaped the special characters in the category descriptions, such as the single
quotes, that need to be doubled, so MySQL will know to interpret those as quotes to be added to the description,
instead of as string termination characters.
Adding Products and Relating Them to Categories
You??™ll now go through the same steps as earlier, but this time, you??™ll create a slightly more
complicated table: product. The product table has the fields shown in Table 5-2.
Table 5-2. Designing the product Table
Field Name Data Type Description
product_id int An integer that represents the unique ID for the
category. It is the primary key of the table and an
autoincrement field.
name varchar(100) Stores the product name. It doesn??™t allow NULLs.
description varchar(1000) Stores the category description. It allows NULLs.
price numeric(10, 2) Stores the product price.
discounted_price numeric(10, 2) Stores the discounted product price. Will store 0.00 if
the product doesn??™t have a current discount price.
image varchar(150) Stores the name of the product??™s picture file (or
eventually the complete path), which gets displayed on
the product details page.


Pages:
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213