In the extra field indicate autoincrement. Why? because in fact, the advantage of this type of field you will be able not to worry about the number to add, MySQL will do it for you. When you add a news item, you will not have to go retrieve the maximum number entered for him and add an insert into the database. Then select the third option (the icon with a U), indicating that this field is a field with a unique value (this is also an index that will allow you to accelerate research on the base, but we come later). For the second field, it is the title of the news. We can name the title field, and put a VARCHAR (put 255 in the size / value). For the third field, this is a release date. You know what a timestamp, we will not use this type of field because the timestamp of PHP and MySQL that are different. However, we will use a type INT UNSIGNED attribute, which will store dates from the time () function of PHP.
For the fourth field, we will use the author name, containing the nick of the poster's news with the type VARCHAR and 20 characters in the size / value. You should know that it would be more efficient to store a number corresponding to a membership number, only we do not have table members and I'm not going to complicate your task for this first year. The final field will be of type TEXT and will be known as text. It used to contain the text of the news. Choose in the "storage engine" option MyISAM. I do not say why, but be aware that some types of tables are not supported with some hosts, this is not the case of MyISAM. This is not dramatic in itself because you can change the table type options via PHPMyAdmin, but other types offer certain features that we will not detail here and can not be adapted. Once everything is completed, click the Save button. If all goes well, PHPMyAdmin execute the following query:
Code:
CREATE TABLE `news` (
`` Id_news MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
`Title` VARCHAR (255) NOT NULL,
`Date` INT UNSIGNED NOT NULL,
`Author` VARCHAR (20) NOT NULL,
`Text` TEXT NOT NULL, UNIQUE (`id_news`))
ENGINE = MyISAM;
After this I am sure that you people will be able to do your own.
Bookmarks