Prev | Current Page 203 | Next

Emilian Balanescu and Cristian Darie

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

Also, if you want to promote products
that have a discounted price, this feature is just
what you need.
The product_category table is the linking table that allows implementing the many-tomany
relationship between the product and category tables. It has two fields that form the
primary key of the table: product_id and category_id.
Follow the steps of the exercise to create the product table in your database.
Exercise: Creating the product Table
1. Using phpMyAdmin, execute the following command to create the product table:
-- Create product table
CREATE TABLE `product` (
`product_id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`description` VARCHAR(1000) NOT NULL,
`price` NUMERIC(10, 2) NOT NULL,
`discounted_price` NUMERIC(10, 2) NOT NULL DEFAULT 0.00,
`image` VARCHAR(150),
`image_2` VARCHAR(150),
`thumbnail` VARCHAR(150),
`display` SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (`product_id`)
) ENGINE=MyISAM;
2. Now, create the product_category table by executing this query:
-- Create product_category table
CREATE TABLE `product_category` (
`product_id` INT NOT NULL,
`category_id` INT NOT NULL,
PRIMARY KEY (`product_id`, `category_id`)
) ENGINE=MyISAM;
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 123
3. Use the populate_product.sql script from the code download to populate the product table with
sample data.


Pages:
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
kreskowka tekstowo opisy gg Monty Python sennik