OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P10

OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P10:A number of years ago, before I started using PHP, I created dynamic web pages using C. This really wasn’t too different from some of the other options available at the time, though it seems almost unthinkable now. Creating a dynamic page meant outputting HTML from your script and recompiling that script if any changes needed to be made. | This is a fairly simple table but it s perfectly adequate for your needs as long as it s populated with a sufficient number of records. The example shows five records per page so at least six records are required. NOTE The SQL to create this table and insert a number of records is available with the downloads for this chapter. Find the file . The code to use the page navigator with a result set is very similar to the code you used when testing the Directoryitems class. I ll comment on the differences only. require require define OFFSET offset get query string offset @ _GET OFFSET max per page define PERPAGE 5 check variable if isset offset recordoffset 0 else calc record offset recordoffset offset PERPAGE To this point the code is identical to the code in Chapter 8 but the MySQLConnect class replaces the Directoryitems class. Remember that the MySQLResultSet class has been included within the file so it doesn t need to be included here with a require statement. category 0@ _GET category check variable if isset category category LIT To demonstrate the versatility of the PageNavigator class another name value pair is passed to this page. In addition to the offset value you pass in O a category value. Doing this allows you to use the identical query for any category of books you choose by simply adding another criterion to the WHERE clause of your SQL. Using the category value also demonstrates as I promised earlier how the final parameter passed to the page navigator in this case otherparameter is used but more about that shortly. Ordering Filtering and Extracting In plain English your SQL statement Listing 9-2 allows you to select the author and title for unsold books in the specified category. The books are ordered by the author name. Database Glosses 71 strsql SELECT author title . FROM tblbooks . WHERE sold 0 AND cat category . ORDER BY author LIMIT O recordoffset . PERPAGE Listing 9-2 The SQL statement

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
476    18    1    29-11-2024
15    22    4    29-11-2024
Đã 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.