Beginning Ajax with PHP From Novice to Professional phần 4

Tham khảo tài liệu 'beginning ajax with php from novice to professional phần 4', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 62 CHAPTER 4 DATABASE-DRIVEN AJAX Similarly your file now does much the same validation checking as your file. This time however rather than checking for an exact match against an array of names the system now checks for an actual database match for the name in question. Again this is far superior as you now have a means to properly store information on saved names. Note that the code flow is largely the same but now it is done properly via a real data storage model and the result is a nicely validated form as shown in Figure 4-4 . php Add in our database connector. require_once And open a database connection. db opendatabase Set up the dynamic query string. querystr SELECT userid FROM user WHERE name LOWER . mysql_real_escape_string _GET sstring . if userquery mysql_query querystr if mysql_num_rows userquery 0 Then return with an error. span style color FF0000 Name not found. span php else At this point we would go to the processing script. span style color FF0000 Form would now submit. span php else echo mysql_error 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 .

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
1    77    2    28-04-2024
36    72    1    28-04-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.