Page 199 - CITS - Computer Software Application -TT
P. 199
COMPUTER SOFTWARE APPLICATION - CITS
Notes on the table above:
The data type specifies what type of data the column can hold.
After the data type, you can specify other optional attributes for each column:
• NOT NULL - Each row must contain a value for that column, null values are not allowed
• DEFAULT value - Set a default value that is added when no other value is passed
• UNSIGNED - Used for number types, limits the stored data to positive numbers and zero
• AUTO INCREMENT - MySQL automatically increases the value of the field by 1 each time a new record is
added
• PRIMARY KEY - Used to uniquely identify the rows in a table. The column with
PRIMARY KEY setting is often an ID number, and is often used with
AUTO_INCREMENT
Each table should have a primary key column (in this case: the “id” column). Its value must be unique for each
record in the table.
The following examples shows how to create the table in PHP:
Example:
Insert Data Into MySQL Using MySQLi
After a database and a table have been created, we can start adding data in them.
Here are some syntax rules to follow:
• The SQL query must be quoted in PHP
• String values inside the SQL query must be quoted
• Numeric values must not be quoted
• The word NULL must not be quoted
186
CITS : IT&ITES - Computer Software Application - Lesson 47 - 62