PHP 5/MySQL Programming- P74

PHP 5/MySQL Programming- P74: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 | This simple program established the connection and ensured that everything was stored as I expected. Whenever I write a data program I usually write something like this that quickly steps through my data to ensure everything is working correctly. There s no point in moving on until you know you have the basic connection. I did not give you a screenshot of this program because it isn t very pretty but I did include it on the CD-ROM so you can run it yourself. The point here is to start small and then turn your basic program into something more sophisticated one step at a time. Displaying One Segment The actual gameplay consists of repeated calls to the program. This program takes a segment ID as its one input and then uses that data to build a page based on that database s record. The only surprise is how simple the code is for this program. html head title Show Segment title style type text css body color red td color white background-color blue width 20 height 3em font-size 20pt style head body if empty room room 1 end if connect to database conn mysql_connect localhost Chapter 10 Connecting to Databases within PHP 344 PHP 5 MySQL Programming for the Absolute Beginner select mysql_select_db chapter7 conn sql SELECT FROM adventure WHERE id room result mysql_query sql mainRow mysql_fetch_assoc result theText mainRow description northButton buildButton north eastButton buildButton east westButton buildButton west southButton buildButton south roomName mainRow name print HERE center h1 roomName h1 center form method post table border 1 tr td td td northButton td td td tr tr td eastButton td td theText td td westButton td tr tr td td td southButton td td td tr table center input type submit value go center form HERE function buildButton dir builds a button for the specified direction global mainRow conn newID mainRow dir print newID is newID query SELECT name FROM adventure WHERE id newID result mysql_query query conn row mysql_fetch_assoc result .

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.