tailieunhanh - Giải pháp thiết kế web động với PHP - p 32
GETTING STARTED WITH MYSQL 11. Click Add a new User, and repeat steps 4 through 8 to create a second user account called psread. This user will have much more restricted privileges, so when you get to step 7, check only the SELECT option. The password used for psread in the example files is K1y0mi$u. Creating a database table Now that you have a database and dedicated user accounts, you can begin creating tables. Let s begin by creating a table to hold the details of images, as shown in Figure 10-1. Before you can start entering data, you need to define the. | GETTING STARTED WITH MYSQL 11. Click Add a new User and repeat steps 4 through 8 to create a second user account called psread. This user will have much more restricted privileges so when you get to step 7 check only the SELECT option. The password used for psread in the example files is K1y0mi u. Creating a database table Now that you have a database and dedicated user accounts you can begin creating tables. Let s begin by creating a table to hold the details of images as shown in Figure 10-1. Before you can start entering data you need to define the table structure. This involves deciding the following The name of the table How many columns it will have The name of each column What type of data will be stored in each column Whether the column must always have data in each field Which column contains the table s primary key If you look at Figure 10-1 you can see that the table contains three columns image_id primary key filename and caption. Because it contains details of images that s a good name to use for the table. There s not much point in storing a filename without a caption so every column must contain data. Great Apart from the data type all the decisions have been made. I ll explain the data types as we go along. Defining the images table These instructions show how to define a table in phpMyAdmin. If you prefer to use Navicat SQLyog or a different UI for MySQL use the settings in Table 10-1. 1. Launch phpMyAdmin if it s not already open and select phpsols from the Database dropdown menu in the left frame. Type the name of the new table images in the field labeled Create new table on database phpsols and enter 3 as the Number of fields. As mentioned before phpMyAdmin refers to columns as fields. What it means is how many fields each record has. Then click the Go button. 2. The next screen is where you define the table. Because the images table contains only three columns the options for each column are listed vertically. When you define a table with more
đang nạp các trang xem trước