tailieunhanh - php solutions dynamic web design made easy phần 9

hoặc không thể tìm thấy ở tất cả. Điều này thường xảy ra nếu bạn đã có một cài đặt trước của PHP và không loại bỏ nó từ thư mục hệ thống Windows. Sau khi chạy phpinfo (), kiểm tra giá trị so với file cấu hình () Path (đó là điểm thứ sáu từ trên) | MANAGING CONTENT need to pass text values to htmlentities to avoid problems with displaying quotes. Display title in the value attribute of the title input field like this input name title type text class widebox id title value php echo htmlentities title 5. Do the same for the article text area. Because text areas don t have a value attribute the code goes between the opening and closing textarea tags like this textarea name article cols 60 rows 8 class widebox id article php echo htmlentities article textarea Make sure there is no space between the opening and closing PHP and textarea tags. Otherwise you will get unwanted spaces in your updated record. 6. The UPDATE command needs to know the primary key of the record you want to change. You need to store the primary key in a hidden field so that it is submitted in the _POST array with the other details. Because hidden fields are not displayed onscreen the following code can go anywhere inside the form input name article_id type hidden value php echo article_id 7. Save the update page and test it by loading into a browser and selecting the EDIT link for one of the records. The contents of the record should be displayed in the form fields as shown in Figure 13-4. The Update entry button doesn t do anything yet. Just make sure that everything is displayed correctly and confirm that the primary key is registered in the hidden field. You can check your code if necessary against . 8. The name attribute of the submit button is update so all the update processing code needs to go in a conditional statement that checks for the presence of update in the _POST array. Place the following code highlighted in bold immediately above the code in step 1 that redirects the page stmt- fetch if form has been submitted update record if array_key_exists update _POST prepare update query sql UPDATE journal SET title article WHERE article_id initialize statement stmt conn- stmt_init if stmt- .

TỪ KHÓA LIÊN QUAN