tailieunhanh - Giải pháp thiết kế web động với PHP - p 47

MANAGING MULTIPLE DATABASE TABLES Figure 16-8. The multiple-choice list pulls the values from the categories table. 7. View the page s source code to verify that the primary key of each category is correctly embedded in the value attribute of each tag. You can compare your code with in the ch16 folder. Next, create the drop-down menu to display the images already registered in the database. Add this code immediately after the code you inserted in step 5: Uploaded image: Select image query($getImages); while ($row = $images-fetch_assoc()) { ? " . | MANAGING MULTIPLE DATABASE TABLES Figure 16-8. The multiple-choice select list pulls the values from the categories table. 7. View the page s source code to verify that the primary key of each category is correctly embedded in the value attribute of each option tag. You can compare your code with in the ch16 folder. 8. Next create the select drop-down menu to display the images already registered in the database. Add this code immediately after the code you inserted in step 5 P label for image_id Uploaded image label select name image_id id image_id option value Select image option php get the list of images getImages SELECT image_id filename FROM images ORDER BY filename images conn- query getImages while row images- fetch_assoc option value php echo row image_id php if isset _POST image_id row image_id _POST image_id echo selected php echo row filename option php select p 441 CHAPTER 16 Download from Wow eBook This creates another SELECT query to get the primary key and filename of each image stored in the images table. The code should be very familiar by now so it needs no explanation. 9. The check box file input field and text input field for the caption go between the code in the previous step and the submit button. The code looks like this p id allowUpload input type checkbox name upload_new id upload_new label for upload_new Upload new image label p p class optional label for image Select image label input type file name image id image p p class optional label for caption Caption label input name caption type text class widebox id caption p The paragraph that contains the check box has been given the ID allowUpload and the two other paragraphs have been assigned a class called optional. The style rules in admin .css set the display property of these three paragraphs to none. 10. Save and load the page in a browser. The images select dropdown menu is displayed below the categories list but the

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.