PHP 5/MySQL Programming- P76

PHP 5/MySQL Programming- P76:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | ma keL1 st d1r Scurrent a list of all the places in the system o 354 PHP 5 MySQL Programming for the Absolute Beginner global conn listCode select name dir n sql SELECT id name FROM adventure result mysql_query sql rowNum 0 while row mysql_fetch_assoc result id row id placeName row name listCode . option value id n select this option if it s the one indicated if rowNum current listCode . selected n end if listCode . placeName option n rowNum end while return listCode end makeList body html Generating Variables After the standard database connection the code creates a number of variables. Some of these variables theText roomName and roomNum are simplifications of the associative array. Another set of variables are the result of the makeList function. This function s job is to return an HTML list box containing the room names of every segment in the database. The list box is set up so that whatever room number is associated with the indicated field is the default. Printing the HTML Code The central part of the program consists of a large print statement that develops the HTML code. The code in this case is a large table enclosed in a form. Every field in the record has a form element associated with it. When the user submits this form it should have all the data necessary to update a record in the database. The one element the user should not be able to directly edit is the room number. This is stored in a hidden field. The directional room numbers are encoded in the list boxes. All other data is in appropriately named text boxes. Creating the List Boxes The list boxes require a little bit of thought to construct. The makeList function expects two parameters. The dir parameter holds the direction field name of the current list box. The current parameter holds information about which room is currently selected for this particular field of the current record. The data connection handler conn is the only global variable. The variable listCode holds the actual HTML code

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
Đã 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.