Beginning Ajax with PHP From Novice to Professional P4

Thực tế là Ajax là khá đơn giản để thực hiện từ một điểm phát triển của xem chỉ đơn thuần là đóng băng trên bánh rất tốt. Nó cho phép các nhà phát triển | CHAPTER 4 DATABASE-DRIVEN AJAX 63 Figure 4-4. Validation now with shiny database functionality Loading the Calendar The next part of your Ajax-powered calendar that is in need of updating is the calendar itself. Naturally since you are dealing with a dynamically created task listing it makes sense that the calendar should retrieve information from the database and load it into each day s task listing. You can achieve such functionality by querying the database for existing records as it checks the calendar days. Consider the changes to that will allow the system to identify any tasks on a given day php Add in the database connector. require_once Open the database. db opendatabase Set up the dynamic query string. querystr SELECT description FROM task WHERE thedate . addslashes _GET thedate . . 64 CHAPTER 4 DATABASE-DRIVEN AJAX if datequery mysql_query querystr if mysql_num_rows datequery 0 div style width 150px background FFBC37 border-style solid border-color 000000 border-width 1px div style padding 10px php while datedata mysql_fetch_array datequery if get_magic_quotes_gpc echo stripslashes datedata description else echo datedata description div div php else echo mysql_error Close the database connection. mysql_close db As you can see you once again load in the database connector script and then call the opendatabase function. Once the database is open it is a simple matter of creating a query that checks for any tasks that have been set up on each particular day. You then use the mysql_num_rows function to determine if a particular day has any tasks set up and the while loop cycles through them with the mysql_fetch_array function to display all tasks. It is also important to clean up afterward. You do so by calling the mysql_close function which will close the link to the database. The results of successful task querying are shown in Figure 4-5. CHAPTER 4 DATABASE-DRIVEN AJAX 65 Figure 4-5. As you can see Ajax has

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
80    290    1    29-06-2024
8    94    2    29-06-2024
9    311    1    29-06-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.