PHP 5/MySQL Programming- P33

PHP 5/MySQL Programming- P33: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 | 138 PHP 5 MySQL Programming for the Absolute Beginner FIGURE This page uses associative arrays to relate countries and states to their capital cities. Examining the Program Imagine that you want to store a list of capital cities. You could certainly store the cities in an array. However if your main interest is in the relationship between a state and its capital it could be difficult to maintain the relationship using arrays. In this particular instance it would be nice if you could use the name of the state as the array index the element s number or position within the array rather than a number. Building an Associative Array Here is the code from which generates the array of state capitals stateCap Alaska Juneau stateCap Indiana Indianapolis stateCap Michigan Lansing The associative array is just like a normal array except the index values are strings. Note that the indices must be inside quotation marks. Once you have created an associative array it is used much like a normal array. print Alaska print stateCap Alaska print br br 139 In Dizzy-array If all this associative array talk is making you dizzy don t panic. It s just a new name for something you re very familiar with. Think about the way HTML attributes work. Each tag has a number of attributes that you can use in any order. For example a standard button might look like this input type button value Save the world. This button has two attributes. Each attribute is made up of a name value pair. The keywords type and value are names or indices or keys depending on how you want to think of it and the terms button and Save the world. are the values associated with those names. Cascading style sheets CSS use a different syntax for exactly the same idea. The CSS element indicates a series of modifications to the paragraph tag p background-color red color yellow font-size 14pt While the syntax is different the same pattern applies. The critical part of a CSS definition is a list of name .

Không thể tạo bản xem trước, hãy bấm tải xuống
111    26    1    28-03-2023
7    7    1    28-03-2023
Đã 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.