TAILIEUCHUNG - PHP for Absolute Beginners PHẦN 4

, người dùng định nghĩa chức năng. "Nếu bạn sử dụng các tuyên bố trở lại bên ngoài của một chức năng, tuyên bố kết thúc việc thực hiện của kịch bản. Cũng giống như tiếng vang và in, trả lại là một cấu trúc của ngôn ngữ PHP, vì vậy không có dấu ngoặc đơn là cần thiết khi bạn sử dụng nó. | CHAPTER 4 WORKING WITH DATABASES Figure 4-4. The artists table populated with two entries To populate the albums table you specify two columns to enter data into then execute four statements simultaneously separating them with a semicolon. Enter the following into the SQL text field and click the Go button INSERT INTO albums artist_id album_name VALUES 1 For Emma Forever Ago 1 Blood Bank - EP 2 Let It Die 2 The Reminder Instead of executing four different commands to insert the albums as you did in the preceding example you can use what is called an extended insert to add all four albums at once. This works by enclosing each entry in parentheses separated by commas. Now if you select the albums table from the left column and browse its contents you see the four entries as well as the automatically assigned album_id values see Figure 4-5 . 104 Download at CHAPTER 4 WORKING WITH DATABASES Figure 4-5. The albums table populated with four entries The SELECT Statement Now that you re comfortable inserting data into your tables you need to figure out how to retrieve it for use with your scripts. You do this using the SELECT statement followed by the column name s you want to retrieve. You specify the table you want to query using the format FROM table_name. For example you can get all album names from the albums table by clicking the SQL tab and inserting the following line of code SELECT album_name FROM albums The result of this query when you execute it in the SQL tab of phpMyAdmin the four album names see Figure 4-6 . Download at 105 CHAPTER 4 WORKING WITH DATABASES Figure 4-6. The result of a query for all album_name column values You re also provided with options to modify the results which enables you to make sure results match certain conditions before they are returned. The WHERE clause is the most common query modifier. For example if you want to retrieve only album titles by Bon Tver you can use a WHERE clause to ensure that returned .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.