html, xhtml, and css all-in-one for dummies
Post on 28-Dec-2016
264 Views
Preview:
TRANSCRIPT
-
A L L - I N - O N E
Making Everything Easier!
$39.99 US / $47.99 CN / 27.99 UK
ISBN 978-0-470-53755-8
Programming Languages/HTML
Go to Dummies.comfor videos, step-by-step examples,
how-to articles, or to shop!
Harris
spine=2.16
HTM
L, XHTM
L,&
CSSA
LL
-IN-O
NE
HTML, XHTML,& CSS
Creating the HTML/XHTML Foundation Styling with CSS Using Positional CSS Client-Side Programming with JavaScript Server-Side Programming with PHP Managing Data with MySQL Into the Future with AJAX Moving from Pages to Sites
Andy Harris
Open the book and find:
The basics of building XHTML documents
What to do with selectors, classes, and styles
How to build flexible layouts
Tips on using HTML5
Secrets of managing files and directories
All about SQL coding
AJAX essentials and how to add events with jQuery
The advantages of a Content Management System
You too can become a Web wizard! Heres how to go from simple pages to super sitesContemplating your first dip into Web page creation, or ready to take your sites to the next level? All you need are these eight minibooks. Newbies can start at the beginning for a complete understanding of basic page creation with HTML5, XHTML, and CSS. If youve been there and done that, jump ahead to managing data with MySQL, building AJAX connections, and more!
Lay the foundation build the skeleton of your pages with XHTML, use CSS to add color and formatting, and create dynamic buttons or menus
Serve it up move to the server and use PHP to program responses to Web requests or connect to databases
Manage data set up a secure data server and create a reliable and trustworthy data back-end for your site
Explore AJAX learn the essentials of AJAX, how to add events and animation, and cool ways to use the UI library
Create super sites understand clients and servers, work with content management systems, and more
Andy Harris taught himself programming because it was fun. Today he teaches computer science, game development, and Web programming at the university level; is a technology consultant for the state of Indiana; and has helped people with disabilities to form their own Web development companies.
8 IN 1BOOKSBOOKS
Valuable bonus programs on CD-ROM
Bonus CD IncludesFirefox browser plus valuable extensions and plugins
Aptana programmers editor that simplifies the process
XAMPP, an easy-to-install server package
Visit the companion Web site at www.dummies.com/go/htmlxhtmlandcssaiofd2e for code and other supporting materials
Valuable bonus tools on CD-ROM!
Covers HTML5 and prior versions of H
TML!2nd Edition
2nd Edition
www.it-ebooks.info
http://www.it-ebooks.info/
-
Mobile Apps
Theres a Dummies App for This and ThatWith more than 200 million books in print and over 1,600 unique titles, Dummies is a global leader in how-to information. Now you can get the same great Dummies information in an App. With topics such as Wine, Spanish, Digital Photography, Certification, and more, youll have instant access to the topics you need to know in a format you can trust.
To get information on all our Dummies apps, visit the following:
www.Dummies.com/go/mobile from your computer.
www.Dummies.com/go/iphone/apps from your phone.
Start with FREE Cheat SheetsCheat Sheets include Checklists Charts Common Instructions And Other Good Stuff!
Get Smart at Dummies.com Dummies.com makes your life easier with 1,000s of answers on everything from removing wallpaper to using the latest version of Windows.
Check out our Videos Illustrated Articles Step-by-Step Instructions
Plus, each month you can win valuable prizes by entering our Dummies.com sweepstakes. *
Want a weekly dose of Dummies? Sign up for Newsletters on Digital Photography Microsoft Windows & Office Personal Finance & Investing Health & Wellness Computing, iPods & Cell Phones eBay Internet Food, Home & Garden
Find out HOW at Dummies.com
*Sweepstakes not currently available in all countries; visit Dummies.com for official rules.
Get More and Do More at Dummies.com
To access the Cheat Sheet created specifically for this book, go to www.dummies.com/cheatsheet/htmlxhtmlandcss
spine=2.16
www.it-ebooks.info
http://www.dummies.comhttp://www.dummies.comhttp://www.dummies.comhttp://www.dummies.comhttp://www.dummies.comhttp://www.dummies.comhttp://www.dummies.com/cheatsheet/htmlxhtmlandcsshttp://www.it-ebooks.info/
-
HTML, XHTML, & CSS
A L L - I N - O N E
FOR
DUMmIES
2ND EDITION
01_9780470537558-ffirs.indd i01_9780470537558-ffirs.indd i 10/7/10 8:24 PM10/7/10 8:24 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
01_9780470537558-ffirs.indd ii01_9780470537558-ffirs.indd ii 10/7/10 8:24 PM10/7/10 8:24 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
by Andy Harris
HTML, XHTML, & CSS
A L L - I N - O N E
FOR
DUMmIES
2ND EDITION
01_9780470537558-ffirs.indd iii01_9780470537558-ffirs.indd iii 10/7/10 8:24 PM10/7/10 8:24 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd EditionPublished byWiley Publishing, Inc.111 River StreetHoboken, NJ 07030-5774
www.wiley.com
Copyright 2011 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit-ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permission Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITH-OUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZA-TION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
For technical support, please visit www.wiley.com/techsupport.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Library of Congress Control Number: 2010937814
ISBN: 978-0-470-53755-8
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
01_9780470537558-ffirs.indd iv01_9780470537558-ffirs.indd iv 10/7/10 8:24 PM10/7/10 8:24 PM
Disclaimer: This eBook does not include ancillary media that was packaged with the printed version of the book.
www.it-ebooks.info
http:/www.wiley.comhttp://www.wiley.com/go/permissionshttp://www.wiley.com/techsupporthttp://www.it-ebooks.info/
-
About the AuthorAndy Harris began his teaching life as a special education teacher. As he was teaching young adults with severe disabilities, he taught himself enough com-puter programming to support his teaching habit with freelance program-ming. Those were the exciting days when computers started to have hard drives, and some computers began communicating with each other over an arcane mechanism some were calling the Internet.
All this time Andy was teaching computer science part time. He joined the faculty of the Indiana University-Purdue University Indianapolis Computer Science department in 1995. He serves as a Senior Lecturer, teaching the introductory courses to freshmen as well as numerous courses on Web development, general programming, and game programming. As manager of the Streaming Media Laboratory, he developed a number of online video-based courses, and worked on a number of international distance education projects including helping to start a computer science program in Tetevo, Macedonia FYR.
Andy is the author of several other computing books including JavaScript For Dummies, Flash Game Programming For Dummies, and Game Programming: the L Line. He invites your comments and questions at andy@aharrisbooks.net. You can visit his main site and fi nd a blog, forum, and links to other books at http://www.aharrisbooks.net.
01_9780470537558-ffirs.indd v01_9780470537558-ffirs.indd v 10/7/10 8:24 PM10/7/10 8:24 PM
www.it-ebooks.info
http://www.aharrisbooks.nethttp://www.it-ebooks.info/
-
01_9780470537558-ffirs.indd vi01_9780470537558-ffirs.indd vi 10/7/10 8:24 PM10/7/10 8:24 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
DedicationI dedicate this book to Jesus Christ, my personal savior, and to Heather, the joy in my life. I also dedicate this project to Elizabeth, Matthew, Jacob, and Benjamin. I love each of you.
Authors AcknowledgmentsThank you fi rst to Heather. Even though I type all the words, this book is a real partnership, like the rest of our life. Thanks for being my best friend and companion. Thanks also for doing all the work it takes for us to sustain a family when Im in writing mode.
Thank you to Mark Enochs. Its great to have an editor who gets me, and whos willing to get excited about a project. I really enjoy working with you.
Thanks very much to Katie Feltman. Its fun to see how far a few wacky ideas have gone. Thanks for continuing to believe in me, and for helping me to always fi nd an interesting new project.
Thank you to the copy editors: fi rst and foremost, I thank Brian Walls for his all his hard work in making this edition presentable. Thanks also go to Teresa Artman, John Edwards, and Melba Hopper for their help. I appreciate your efforts to make my geeky mush turn into something readable. Thanks for improving my writing.
A special thanks to Jeff Noble for his technical editing. I appreciate your vigi-lance. You have helped to make this book as technically accurate as possible.
Thank you to the many people at Wiley who contribute to a project like this. The author only gets to meet a few people, but so many more are involved in the process. Thank you very much for all youve done to help make this project a reality.
Thanks to Chris McCulloh for all you did on the fi rst edition, and I thank you for your continued friendship.
A big thank you to the open source community which has created so many incredible tools and made them available to all. Id especially like to thank the creators of Firefox, Firebug, Aptana, HTML Validator, the Web Developer tool-bar, Ubuntu and the Linux community, Notepad++, PHP, Apache, jQuery, and the various jQuery plugins. This is an amazing and generous community effort.
Id fi nally like to thank the IUPUI computer science family for years of support on various projects. Thank you especially to all my students, current and past. Ive learned far more from you than the small amount Ive taught. Thank you for letting me be a part of your education.
01_9780470537558-ffirs.indd vii01_9780470537558-ffirs.indd vii 10/7/10 8:24 PM10/7/10 8:24 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Publishers AcknowledgmentsWere proud of this book; please send us your comments through our online registration form located at http://dummies.custhelp.com. For other comments, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and Media Development
Senior Project Editor: Mark Enochs
Senior Acquisitions Editor: Katie Feltman
Copy Editors: Brian Walls, Teresa Artman, John Edwards, Melba Hopper
Technical Editor: Jeff Noble
Editorial Manager: Leah Cameron
Media Development Project Manager: Laura Moss-Hollister
Media Development Assistant Project Manager: Jenny Swisher
Media Development Assistant Producer: Shawn Patrick
Editorial Assistant: Amanda Graham
Sr. Editorial Assistant: Cherie Case
Cartoons: Rich Tennant (www.the5thwave.com)
Composition Services
Project Coordinators: Katherine Crocker, Lynsey Stanford
Layout and Graphics: Carl Byers, Timothy C. Detrick
Proofreaders: Lauren Mandelbaum, Christine Sabooni
Indexer: BIM Indexing & Proofreading Services
Special Help: Tonya Cupp, Colleen Totz Diamond
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Composition Services
Debbie Stailey, Director of Composition Services
01_9780470537558-ffirs.indd viii01_9780470537558-ffirs.indd viii 10/7/10 8:24 PM10/7/10 8:24 PM
www.it-ebooks.info
http://www.dummies.custhelp.comhttp://www.the5thwave.comhttp://www.it-ebooks.info/
-
Contents at a GlanceIntroduction ................................................................ 1
Book I: Creating the HTML/XHTML Foundation .............. 7Chapter 1: Sound HTML Foundations ............................................................................. 9Chapter 2: Its All about Validation ............................................................................... 19Chapter 3: Choosing Your Tools .................................................................................... 41Chapter 4: Managing Information with Lists and Tables ............................................ 65Chapter 5: Making Connections with Links .................................................................. 83Chapter 6: Adding Images ............................................................................................... 93Chapter 7: Creating Forms ............................................................................................ 121Chapter 8: The Future of HTML: HTML 5 .................................................................... 141
Book II: Styling with CSS ......................................... 157Chapter 1: Coloring Your World .................................................................................. 159Chapter 2: Styling Text .................................................................................................. 177Chapter 3: Selectors, Class, and Style ......................................................................... 201Chapter 4: Borders and Backgrounds ......................................................................... 219Chapter 5: Levels of CSS................................................................................................ 239
Book III: Using Positional CSS .................................. 257Chapter 1: Fun with the Fabulous Float ...................................................................... 259Chapter 2: Building Floating Page Layouts ................................................................. 279Chapter 3: Styling Lists and Menus ............................................................................. 299Chapter 4: Using Alternative Positioning .................................................................... 317
Book IV: Client-Side Programming with JavaScript ..... 335Chapter 1: Getting Started with JavaScript ................................................................ 337Chapter 2: Making Decisions with Conditions ........................................................... 359Chapter 3: Loops and Debugging ................................................................................. 373Chapter 4: Functions, Arrays, and Objects ................................................................. 395Chapter 5: Talking to the Page ..................................................................................... 423Chapter 6: Getting Valid Input ...................................................................................... 445Chapter 7: Animating Your Pages ................................................................................ 467
02_9780470537558-ftoc.indd ix02_9780470537558-ftoc.indd ix 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Book V: Server-Side Programming with PHP .............. 499Chapter 1: Getting Started on the Server .................................................................... 501Chapter 2: PHP and XHTML Forms .............................................................................. 519Chapter 3: Control Structures ...................................................................................... 539Chapter 4: Working with Arrays .................................................................................. 559Chapter 5: Using Functions and Session Variables ................................................... 579Chapter 6: Working with Files and Directories .......................................................... 591Chapter 7: Connecting to a MySQL Database............................................................. 613
Book VI: Managing Data with MySQL ....................... 635Chapter 1: Getting Started with Data .......................................................................... 637Chapter 2: Managing Data with SQL ............................................................................ 665Chapter 3: Normalizing Your Data ............................................................................... 691Chapter 4: Putting Data Together with Joins ............................................................. 705
Book VII: Into the Future with AJAX ......................... 729Chapter 1: AJAX Essentials ........................................................................................... 731Chapter 2: Improving JavaScript and AJAX with jQuery .......................................... 747Chapter 3: Animating jQuery ........................................................................................ 771Chapter 4: Using the jQuery User Interface Toolkit .................................................. 797Chapter 5: Improving Usability with jQuery ............................................................... 823Chapter 6: Working with AJAX Data ............................................................................ 843
Book VIII: Moving from Pages to Sites ....................... 867Chapter 1: Managing Your Servers .............................................................................. 869Chapter 2: Planning Your Sites .................................................................................... 895Chapter 3: Introducing Content Management Systems ............................................ 915Chapter 4: Editing Graphics ......................................................................................... 941Chapter 5: Taking Control of Content ......................................................................... 961
Appendix A: Whats on the CD .................................. 979
Index ...................................................................... 985
02_9780470537558-ftoc.indd x02_9780470537558-ftoc.indd x 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of ContentsIntroduction ................................................................. 1
No Experience Necessary ............................................................................... 2Great for Advanced Folks, Too! ..................................................................... 2Use Any Computer ........................................................................................... 3Dont Buy Any Software .................................................................................. 3How This Book Is Organized .......................................................................... 4New for the Second Edition ............................................................................ 5Icons Used in This Book ................................................................................. 6Whats Next? ..................................................................................................... 6
Book I: Creating the HTML/XHTML Foundation ............... 7
Chapter 1: Sound HTML Foundations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9Creating a Basic Page ...................................................................................... 9Understanding the HTML in the Basic Page ............................................... 11Meeting Your New Friends, the Tags .......................................................... 12Setting Up Your System ................................................................................ 15
Displaying fi le extensions ................................................................... 15Setting up your software ..................................................................... 16
Chapter 2: Its All about Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19Somebody Stop the HTML Madness! .......................................................... 19
XHTML to the rescue ........................................................................... 20Theres XHTML and theres good XHTML ........................................ 21
Building an XHTML Document ..................................................................... 22Dont memorize all this! ...................................................................... 22The DOCTYPE tag ................................................................................ 22The xmlns attribute ............................................................................. 23The meta tag ......................................................................................... 23You validate me ................................................................................... 23
Validating Your Page ..................................................................................... 25Aesop visits W3C ................................................................................. 27Showing off your mad skillz ................................................................ 35Using Tidy to repair pages .................................................................. 37
02_9780470537558-ftoc.indd xi02_9780470537558-ftoc.indd xi 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxii
Chapter 3: Choosing Your Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41Whats Wrong with the Big Boys? ............................................................... 41Alternative Web Development Tools .......................................................... 43
The features you need on your computer ........................................ 43Building a basic toolbox...................................................................... 43
Picking a Text Editor ..................................................................................... 44Tools to avoid unless you have nothing else ................................... 44A noteworthy editor: Notepad++ ....................................................... 45The old standards: VI and Emacs ...................................................... 46Other text editors ................................................................................ 49
The Web Developers Browser .................................................................... 49A little ancient history ......................................................................... 49Overview of the prominent browsers ............................................... 50Other notable browsers ...................................................................... 52The bottom line in browsers .............................................................. 53
Tricking Out Firefox ...................................................................................... 53Validating your pages with HTML Validator .................................... 54Using the Web Developer toolbar ...................................................... 55Using Firebug ........................................................................................ 57
Using a Full-Blown IDE .................................................................................. 58Introducing Aptana .............................................................................. 58Customizing Aptana............................................................................. 60
Introducing Komodo Edit ............................................................................. 62
Chapter 4: Managing Information with Lists and Tables . . . . . . . . . . .65Making a List and Checking It Twice ........................................................... 65
Creating an unordered list .................................................................. 65Creating ordered lists .......................................................................... 67Making nested lists .............................................................................. 69Building the defi nition list .................................................................. 72
Building Tables .............................................................................................. 74Defi ning the table ................................................................................. 75Spanning rows and columns............................................................... 77Avoiding the table-based layout trap ................................................ 80
Chapter 5: Making Connections with Links . . . . . . . . . . . . . . . . . . . . . .83Making Your Text Hyper ............................................................................... 83
Introducing the anchor tag ................................................................. 84Comparing block-level and inline elements...................................... 85Analyzing an anchor ............................................................................ 86Introducing URLs ................................................................................. 86
Making Lists of Links ..................................................................................... 88Working with Absolute and Relative References ...................................... 89
Understanding absolute references .................................................. 89Introducing relative references .......................................................... 89
02_9780470537558-ftoc.indd xii02_9780470537558-ftoc.indd xii 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of Contents xiii
Chapter 6: Adding Images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93Adding Images to Your Pages ...................................................................... 93
Adding links to images ........................................................................ 94Adding inline images using the tag ........................................ 96
Choosing an Image Manipulation Tool ....................................................... 98An image is worth 3.4 million words! ................................................ 98Introducing IrfanView ........................................................................ 101
Choosing an Image Format ......................................................................... 102BMP ...................................................................................................... 102JPG/JPEG ............................................................................................. 102GIF ........................................................................................................ 103PNG ...................................................................................................... 105Summary of Web image formats ...................................................... 106
Manipulating Your Images .......................................................................... 106Changing formats in IrfanView ......................................................... 106Resizing your images ......................................................................... 108Enhancing image colors .................................................................... 109Using built-in effects .......................................................................... 110Other effects you can use ................................................................. 115Batch processing ............................................................................... 115
Using Images as Links ................................................................................. 117Creating thumbnail images ............................................................... 118Creating a thumbnail-based image directory ................................. 120
Chapter 7: Creating Forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121You Have Great Form .................................................................................. 121
Forms must have some form ............................................................ 123Organizing a form with fi eldsets and labels ................................... 123
Building Text-Style Inputs .......................................................................... 126Making a standard text fi eld ............................................................. 126Building a password fi eld .................................................................. 127Making multi-line text input .............................................................. 128
Creating Multiple Selection Elements ....................................................... 130Making selections .............................................................................. 130Building check boxes......................................................................... 132Creating radio buttons ...................................................................... 134
Pressing Your Buttons ................................................................................ 136Making input-style buttons ............................................................... 137Building a Submit button .................................................................. 138Its a do-over: The Reset button ....................................................... 138Introducing the tag ........................................................... 139
Chapter 8: The Future of HTML: HTML 5. . . . . . . . . . . . . . . . . . . . . . . . .141Cant We Just Stick with XHTML? .............................................................. 141
Using the HTML 5 doctype ............................................................... 142Browser support for HTML 5 ........................................................... 142Validating HTML 5 ............................................................................. 142
02_9780470537558-ftoc.indd xiii02_9780470537558-ftoc.indd xiii 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxiv
Semantic Elements ...................................................................................... 142Using New Form Elements .......................................................................... 144Using Embedded Fonts ............................................................................... 147Audio and Video Tags ................................................................................. 149The Canvas Tag ............................................................................................ 152Other Promising Features .......................................................................... 155Limitations of HTML 5 ................................................................................. 156
Book II: Styling with CSS .......................................... 157
Chapter 1: Coloring Your World. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159Now You Have an Element of Style ........................................................... 159
Setting up a style sheet ..................................................................... 161Changing the colors ........................................................................... 162
Specifying Colors in CSS ............................................................................. 163Using color names ............................................................................. 163Putting a hex on your colors ............................................................ 164Coloring by number ........................................................................... 165Hex education..................................................................................... 165Using the Web-safe color palette ..................................................... 167
Choosing Your Colors ................................................................................. 168Starting with Web-safe colors .......................................................... 169Modifying your colors ....................................................................... 169Doing it on your own pages .............................................................. 170Changing CSS on the fl y..................................................................... 170
Creating Your Own Color Scheme ............................................................. 172Understanding hue, saturation, and value ..................................... 172Using the Color Scheme Designer .................................................... 173Selecting a base hue .......................................................................... 174Picking a color scheme ..................................................................... 175
Chapter 2: Styling Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177Setting the Font Family ............................................................................... 177
Applying the font-family style attribute .......................................... 179Using generic fonts ............................................................................ 180Making a list of fonts ......................................................................... 181
The Curse of Web-Based Fonts .................................................................. 183Understanding the problem ............................................................. 183Examining possible solutions ........................................................... 184Using images for headlines ............................................................... 185
Specifying the Font Size .............................................................................. 188Size is only a suggestion!................................................................... 188Using the font-size style attribute .................................................... 188Absolute measurement units ........................................................... 189Relative measurement units ............................................................. 190
02_9780470537558-ftoc.indd xiv02_9780470537558-ftoc.indd xiv 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of Contents xv
Determining Other Font Characteristics .................................................. 191Using font-style for italics ................................................................. 192Using font-weight for bold ................................................................ 193Using text-decoration ........................................................................ 194Using text-align for basic alignment ................................................ 196Other text attributes.......................................................................... 197Using the font shortcut ..................................................................... 197Working with subscripts and superscripts .................................... 199
Chapter 3: Selectors, Class, and Style . . . . . . . . . . . . . . . . . . . . . . . . . .201Selecting Particular Segments .................................................................... 201
Defi ning more than one kind of paragraph ..................................... 201Styling identifi ed paragraphs ........................................................... 203
Using Emphasis and Strong Emphasis ...................................................... 203Adding emphasis to the page ........................................................... 204Modifying the display of em and strong ......................................... 204
Defi ning Classes ........................................................................................... 206Adding classes to the page ............................................................... 207Combining classes ............................................................................. 208
Introducing div and span ............................................................................ 210Organizing the page by meaning...................................................... 211Why not make a table? ...................................................................... 212
Using Pseudo-Classes to Style Links ......................................................... 213Styling a standard link ....................................................................... 213Styling the link states ........................................................................ 213Best link practices ............................................................................. 215
Selecting in Context ..................................................................................... 216Defi ning Multiple Styles at Once ................................................................ 217
Chapter 4: Borders and Backgrounds. . . . . . . . . . . . . . . . . . . . . . . . . . .219Joining the Border Patrol ........................................................................... 219
Using the border attributes .............................................................. 219Defi ning border styles ....................................................................... 221Using the border shortcut ................................................................ 222Creating partial borders.................................................................... 222
Introducing the Box Model ......................................................................... 224Borders, margin, and padding .......................................................... 224Positioning elements with margins and padding ........................... 226
Changing the Background Image ............................................................... 228Getting a background check ............................................................. 230Solutions to the background conundrum ....................................... 230
Manipulating Background Images ............................................................. 234Turning off the repeat ....................................................................... 234Making effective gradients with repeat-x and repeat-y ................. 235
Using Images in Lists ................................................................................... 237
02_9780470537558-ftoc.indd xv02_9780470537558-ftoc.indd xv 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxvi
Chapter 5: Levels of CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239Managing Levels of Style ............................................................................ 239
Using local styles ............................................................................... 239Using an external style sheet ........................................................... 242
Understanding the Cascading Part of Cascading Style Sheets .............. 246Inheriting styles ................................................................................. 247Hierarchy of styles ............................................................................. 248Overriding styles ................................................................................ 249Precedence of style defi nitions ........................................................ 250
Using Conditional Comments ..................................................................... 251Coping with incompatibility ............................................................. 251Making Internet Explorerspecifi c code ......................................... 252Using a conditional comment with CSS .......................................... 253Checking the Internet Explorer version .......................................... 256
Book III: Using Positional CSS ................................... 257
Chapter 1: Fun with the Fabulous Float . . . . . . . . . . . . . . . . . . . . . . . . .259Avoiding Old-School Layout Pitfalls .......................................................... 259
Problems with frames ....................................................................... 259Problems with tables ......................................................................... 260Problems with huge images.............................................................. 261Problems with Flash .......................................................................... 261
Introducing the Floating Layout Mechanism ........................................... 262Using fl oat with images ..................................................................... 263Adding the fl oat property ................................................................. 264
Using Float with Block-Level Elements ..................................................... 265Floating a paragraph.......................................................................... 265Adjusting the width ........................................................................... 267Setting the next margin ..................................................................... 268
Using Float to Style Forms .......................................................................... 270Using fl oat to beautify the form ....................................................... 272Adjusting the fi eldset width.............................................................. 275Using the clear attribute to control page layout ........................... 276
Chapter 2: Building Floating Page Layouts . . . . . . . . . . . . . . . . . . . . . .279Creating a Basic Two-Column Design ....................................................... 279
Designing the page ............................................................................. 279Building the XHTML .......................................................................... 281Adding preliminary CSS .................................................................... 282Using temporary borders ................................................................. 283Setting up the fl oating columns ....................................................... 285Tuning up the borders ...................................................................... 285Advantages of a fl uid layout ............................................................. 287
02_9780470537558-ftoc.indd xvi02_9780470537558-ftoc.indd xvi 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of Contents xvii
Building a Three-Column Design ............................................................... 287Styling the three-column page ......................................................... 289Problems with the fl oating layout.................................................... 290Specifying a min-height ..................................................................... 291
Building a Fixed-Width Layout ................................................................... 293Setting up the XHTML ....................................................................... 293Using an image to simulate true columns ....................................... 294
Building a Centered Fixed-Width Layout .................................................. 295Making a surrogate body with an all div ......................................... 296How the jello layout works ............................................................... 298Limitations of the jello layout .......................................................... 298
Chapter 3: Styling Lists and Menus. . . . . . . . . . . . . . . . . . . . . . . . . . . . .299Revisiting List Styles ................................................................................... 299
Defi ning navigation as a list of links ................................................ 300Turning links into buttons ................................................................ 300Building horizontal lists .................................................................... 302
Creating Dynamic Lists ............................................................................... 304Building a nested list ......................................................................... 304Hiding the inner lists ......................................................................... 306Getting the inner lists to appear on cue ......................................... 307
Building a Basic Menu System ................................................................... 310Building a vertical menu with CSS ................................................... 312Building a horizontal menu .............................................................. 314
Chapter 4: Using Alternative Positioning. . . . . . . . . . . . . . . . . . . . . . . .317Working with Absolute Positioning ........................................................... 317
Setting up the HTML .......................................................................... 318Adding position guidelines ............................................................... 318Making absolute positioning work................................................... 319
Managing z-index ......................................................................................... 320Handling depth ................................................................................... 320Working with z-index ......................................................................... 322
Building a Page Layout with Absolute Positioning .................................. 322Overview of absolute layout ............................................................. 322Writing the XHTML ............................................................................ 324Adding the CSS ................................................................................... 324
Creating a More Flexible Layout ................................................................ 326Designing with percentages.............................................................. 326Building the layout............................................................................. 328
Exploring Other Types of Positioning ....................................................... 329Creating a fi xed menu system .......................................................... 330Setting up the XHTML ....................................................................... 331Setting the CSS values ....................................................................... 332
Determining Your Layout Scheme ............................................................. 334
02_9780470537558-ftoc.indd xvii02_9780470537558-ftoc.indd xvii 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxviii
Book IV: Client-Side Programming with JavaScript ..... 335
Chapter 1: Getting Started with JavaScript. . . . . . . . . . . . . . . . . . . . . .337Working in JavaScript ................................................................................. 337
Choosing a JavaScript editor ............................................................ 338Picking your test browser ................................................................. 339
Writing Your First JavaScript Program ..................................................... 340Embedding your JavaScript code .................................................... 341Creating comments ............................................................................ 342Using the alert( ) method for output ............................................... 342Adding the semicolon........................................................................ 342
Introducing Variables .................................................................................. 342Creating a variable for data storage ................................................ 344Asking the user for information ....................................................... 344Responding to the user ..................................................................... 345
Using Concatenation to Build Better Greetings ....................................... 345Comparing literals and variables ..................................................... 347Including spaces in your concatenated phrases ........................... 347
Understanding the String Object ............................................................... 347Introducing object-based programming (and cows)..................... 348Investigating the length of a string .................................................. 348Using string methods to manipulate text ....................................... 349
Understanding Variable Types .................................................................. 352Adding numbers ................................................................................. 352Adding the users numbers .............................................................. 353The trouble with dynamic data ........................................................ 354The pesky plus sign ........................................................................... 355
Changing Variables to the Desired Type .................................................. 356Using variable conversion tools ...................................................... 356Fixing the addInput code .................................................................. 357
Chapter 2: Making Decisions with Conditions . . . . . . . . . . . . . . . . . . .359Working with Random Numbers ............................................................... 359
Creating an integer within a range................................................... 359Building a program that rolls dice ................................................... 360
Using if to Control Flow .............................................................................. 361The basic if statement ....................................................................... 362All about conditions .......................................................................... 363Comparison operators ...................................................................... 363
Using the else Clause .................................................................................. 364Using if-else for more complex interaction .................................... 365Solving the mystery of the unnecessary else ................................. 367
Using switch for More Complex Branches ............................................... 367Creating an expression...................................................................... 368Switching with style ........................................................................... 369
02_9780470537558-ftoc.indd xviii02_9780470537558-ftoc.indd xviii 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of Contents xix
Nesting if Statements .................................................................................. 370Building the nested conditions ........................................................ 371Making sense of nested ifs ................................................................ 372
Chapter 3: Loops and Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373Building Counting Loops with for .............................................................. 373
Building a standard for loop ............................................................. 374Counting backward ............................................................................ 375Counting by 5 ..................................................................................... 375
Looping for a while ...................................................................................... 377Creating a basic while loop .............................................................. 377Avoiding loop mistakes ..................................................................... 378
Introducing Bad Loops ............................................................................... 378Managing the reluctant loop ............................................................ 379Managing the obsessive loop ........................................................... 379
Debugging Your Code ................................................................................. 380Letting Aptana help ........................................................................... 380Debugging JavaScript on Internet Explorer .................................... 381Finding errors in Firefox ................................................................... 383Finding errors with Firebug .............................................................. 383
Catching Logic Errors ................................................................................. 384Logging to the console with Firebug ............................................... 385Looking at console output ................................................................ 386
Using the Interactive Debug Mode ............................................................ 387Setting up the Firebug debugger ...................................................... 388Setting a breakpoint ......................................................................... 389Adding a debugger directive ............................................................ 389Examining debug mode ..................................................................... 390Debugging your code......................................................................... 392
Chapter 4: Functions, Arrays, and Objects. . . . . . . . . . . . . . . . . . . . . . .395Breaking Code into Functions .................................................................... 395
Thinking about structure .................................................................. 396Building the antsFunction.html program........................................ 397
Passing Data to and from Functions ......................................................... 398Examining the main code .................................................................. 399Looking at the chorus ....................................................................... 400Handling the verses ........................................................................... 400
Managing Scope ........................................................................................... 402Introducing local and global variables ............................................ 402Examining variable scope ................................................................. 402
Building a Basic Array ................................................................................. 405Accessing array data ......................................................................... 405Using arrays with for loops .............................................................. 406Revisiting the ants song .................................................................... 407
02_9780470537558-ftoc.indd xix02_9780470537558-ftoc.indd xix 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxx
Working with Two-Dimension Arrays ....................................................... 409Setting up the arrays ......................................................................... 410Getting a city ...................................................................................... 411Creating a main( ) function ............................................................... 411
Creating Your Own Objects ........................................................................ 413Building a basic object ...................................................................... 413Adding methods to an object ........................................................... 414Building a reusable object ................................................................ 415Using your shiny new objects .......................................................... 417
Introducing JSON ......................................................................................... 417Storing data in JSON format ............................................................. 418Building a more complex JSON structure ....................................... 419
Chapter 5: Talking to the Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423Understanding the Document Object Model ........................................... 423
Navigating the DOM ........................................................................... 423Changing DOM properties with Firebug ......................................... 425Examining the document object ...................................................... 425
Harnessing the DOM through JavaScript ................................................. 427Getting the blues, JavaScript-style .................................................. 427Writing JavaScript code to change colors ...................................... 428
Managing Button Events ............................................................................. 428Embedding quotes within quotes .................................................... 431Writing the changeColor function ................................................... 431
Managing Text Input and Output ............................................................... 432Introducing event-driven programming .......................................... 432Creating the XHTML form ................................................................. 433Using GetElementById to get access to the page .......................... 434Manipulating the text fi elds .............................................................. 435
Writing to the Document ............................................................................ 436Preparing the HTML framework ...................................................... 436Writing the JavaScript ....................................................................... 437Finding your innerHTML ................................................................. 438
Working with Other Text Elements ........................................................... 438Building the form ............................................................................... 440Writing the function........................................................................... 441Understanding generated source .................................................... 442
Chapter 6: Getting Valid Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .445Getting Input from a Drop-Down List ........................................................ 445
Building the form ............................................................................... 446Reading the list box ........................................................................... 447
Managing Multiple Selections .................................................................... 448Coding a multiple selection select object ....................................... 449Writing the JavaScript code ............................................................. 450
02_9780470537558-ftoc.indd xx02_9780470537558-ftoc.indd xx 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of Contents xxi
Check, Please: Reading Check Boxes ........................................................ 452Building the check box page ............................................................ 452Responding to the check boxes ....................................................... 453
Working with Radio Buttons ...................................................................... 454Interpreting radio buttons ................................................................ 456
Working with Regular Expressions ........................................................... 457Introducing regular expressions ...................................................... 460Using characters in regular expressions ........................................ 462Marking the beginning and end of the line ..................................... 463Working with special characters ..................................................... 463Conducting repetition operations ................................................... 464Working with pattern memory ......................................................... 465
Chapter 7: Animating Your Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .467Making Things Move ................................................................................... 467
Looking over the HTML..................................................................... 468Getting an overview of the JavaScript ............................................. 470Creating global variables .................................................................. 471Initializing............................................................................................ 472Moving the sprite ............................................................................... 472Checking the boundaries .................................................................. 474
Reading Input from the Keyboard ............................................................. 475Building the keyboard page .............................................................. 476Overwriting the init( ) function ........................................................ 477Setting up an event handler .............................................................. 478Responding to keystrokes ................................................................ 479Deciphering the mystery of key codes ............................................ 480
Following the Mouse ................................................................................... 481Looking over the HTML..................................................................... 481Initializing the code ........................................................................... 482Building the mouse listener .............................................................. 483
Creating Automatic Motion ........................................................................ 483Creating a setInterval( ) call ............................................................. 485
Building Image-Swapping Animation ......................................................... 486Preparing the images ......................................................................... 487Building the page ............................................................................... 487Building the global variables ............................................................ 488Setting up the interval ....................................................................... 489Animating the sprite .......................................................................... 489
Preloading Your Images .............................................................................. 490Movement and swapping .................................................................. 492Building the code ............................................................................... 494Defi ning global variables ................................................................... 495Initializing your data .......................................................................... 496Preloading the images ....................................................................... 496Animating and updating the image .................................................. 497Moving the sprite ............................................................................... 497
02_9780470537558-ftoc.indd xxi02_9780470537558-ftoc.indd xxi 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxxii
Book V: Server-Side Programming with PHP ............... 499
Chapter 1: Getting Started on the Server . . . . . . . . . . . . . . . . . . . . . . . .501Introducing Server-Side Programming ...................................................... 501
Programming on the server .............................................................. 501Serving your programs ...................................................................... 502Picking a language ............................................................................. 503
Installing Your Web Server ......................................................................... 504Inspecting phpinfo( ) ................................................................................... 505Building XHTML with PHP .......................................................................... 508Coding with Quotation Marks .................................................................... 510Working with Variables PHP-Style ............................................................. 511
Concatenation .................................................................................... 512Interpolating variables into text ...................................................... 513
Building XHTML Output ............................................................................. 514Using double quote interpolation .................................................... 515Generating output with heredocs .................................................... 515Switching from PHP to XHTML ........................................................ 517
Chapter 2: PHP and XHTML Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . .519Exploring the Relationship between PHP and XHTML ........................... 519
Embedding PHP inside XHTML ........................................................ 520Viewing the results ............................................................................ 521
Sending Data to a PHP Program ................................................................. 522Creating a form for PHP processing ................................................ 523Receiving data in PHP ....................................................................... 525
Choosing the Method of Your Madness ................................................... 527Using get to send data ....................................................................... 527Using the post method to transmit form data ............................... 529Getting data from the form ............................................................... 530
Retrieving Data from Other Form Elements ............................................. 532Building a form with complex elements ......................................... 532Responding to a complex form ........................................................ 535
Chapter 3: Control Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .539Introducing Conditions (Again) ................................................................. 539Building the Classic if Statement ............................................................... 540
Rolling dice the PHP way .................................................................. 541Checking your six............................................................................... 541Understanding comparison operators ............................................ 545Taking the middle road ..................................................................... 545Building a program that makes its own form ................................. 547
Making a switch ........................................................................................... 549Looping with for .......................................................................................... 552Looping with while ...................................................................................... 555
02_9780470537558-ftoc.indd xxii02_9780470537558-ftoc.indd xxii 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of Contents xxiii
Chapter 4: Working with Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .559Using One-Dimensional Arrays .................................................................. 559
Creating an array ............................................................................... 559Filling an array .................................................................................... 560Viewing the elements of an array .................................................... 560Preloading an array ........................................................................... 562
Using Loops with Arrays ............................................................................ 562Simplifying loops with foreach ......................................................... 564Arrays and HTML ............................................................................... 565
Introducing Associative Arrays ................................................................. 567Using foreach with associative arrays ............................................ 568
Introducing Multidimensional Arrays ....................................................... 570Were going on a trip ......................................................................... 570Looking up the distance .................................................................... 572
Breaking a String into an Array .................................................................. 574Creating arrays with explode ........................................................... 574Creating arrays with preg_split........................................................ 576
Chapter 5: Using Functions and Session Variables . . . . . . . . . . . . . . .579Creating Your Own Functions .................................................................... 579
Rolling dice the old-fashioned way .................................................. 579Improving code with functions ........................................................ 582Managing variable scope .................................................................. 583Returning data from functions ......................................................... 585
Managing Persistence with Session Variables ......................................... 586Understanding session variables ..................................................... 587Adding session variables to your code ........................................... 589
Chapter 6: Working with Files and Directories . . . . . . . . . . . . . . . . . .591Text File Manipulation ................................................................................ 591
Writing text to fi les ............................................................................ 592Writing a basic text fi le...................................................................... 594Reading from the fi le ......................................................................... 599
Using Delimited Data ................................................................................... 601Storing data in a CSV fi le ................................................................... 601Viewing CSV data directly ................................................................. 603Reading the CSV data in PHP ............................................................ 604
Working with File and Directory Functions ............................................. 608opendir( ) ............................................................................................ 608readdir( ) ............................................................................................. 608chdir( ) ................................................................................................ 609Generating the list of fi le links .......................................................... 609
Chapter 7: Connecting to a MySQL Database . . . . . . . . . . . . . . . . . . . .613Retrieving Data from a Database ............................................................... 613
Understanding data connections ..................................................... 616Building a connection ........................................................................ 617
02_9780470537558-ftoc.indd xxiii02_9780470537558-ftoc.indd xxiii 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxxiv
Passing a query to the database ...................................................... 618Processing the results ....................................................................... 619Extracting the rows ........................................................................... 620Extracting fi elds from a row ............................................................. 621Printing the data ................................................................................ 622
Improving the Output Format .................................................................... 623Building defi nition lists ..................................................................... 623Using XHTML tables for output ....................................................... 625
Allowing User Interaction ........................................................................... 628Building an XHTML search form ...................................................... 629Responding to the search request................................................... 630Breaking the code into functions ..................................................... 631Processing the input .......................................................................... 632Generating the output ....................................................................... 633
Book VI: Managing Data with MySQL ........................ 635
Chapter 1: Getting Started with Data . . . . . . . . . . . . . . . . . . . . . . . . . . .637Examining the Basic Structure of Data ..................................................... 637
Determining the fi elds in a record ................................................... 639Introducing SQL data types .............................................................. 639Specifying the length of a record ..................................................... 640Defi ning a primary key ...................................................................... 641Defi ning the table structure .............................................................. 642
Introducing MySQL ...................................................................................... 643Why use MySQL? ................................................................................ 643Understanding the three-tier architecture ..................................... 644Practicing with MySQL ...................................................................... 645
Setting Up phpMyAdmin ............................................................................. 646Changing the root password ............................................................ 648Adding a user...................................................................................... 653Using phpMyAdmin on a remote server ......................................... 656
Making a Database with phpMyAdmin ..................................................... 659
Chapter 2: Managing Data with SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . .665Writing SQL Code by Hand ......................................................................... 665
Understanding SQL syntax rules...................................................... 666Examining the buildContact.sql script ............................................ 666Dropping a table................................................................................. 667Creating a table .................................................................................. 667Adding records to the table.............................................................. 668Viewing the sample data ................................................................... 669
Running a Script with phpMyAdmin ......................................................... 669Using AUTO_INCREMENT for Primary Keys ............................................ 672Selecting Data from Your Tables ............................................................... 674
Selecting only a few fi elds ................................................................. 675Selecting a subset of records ........................................................... 677
02_9780470537558-ftoc.indd xxiv02_9780470537558-ftoc.indd xxiv 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
Table of Contents xxv
Searching with partial information .................................................. 679Searching for the ending value of a fi eld ......................................... 680Searching for any text in a fi eld........................................................ 681Searching with regular expressions ................................................ 681Sorting your responses ..................................................................... 682
Editing Records ............................................................................................ 684Updating a record .............................................................................. 684Deleting a record................................................................................ 684
Exporting Your Data and Structure ........................................................... 685Exporting SQL code ........................................................................... 688Creating XML data ............................................................................. 690
Chapter 3: Normalizing Your Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .691Recognizing Problems with Single-Table Data ......................................... 691
The identity crisis .............................................................................. 692The listed powers .............................................................................. 692Repetition and reliability .................................................................. 694Fields that change .............................................................................. 695Deletion problems ............................................................................. 695
Introducing Entity-Relationship Diagrams ............................................... 695Using MySQL Workbench to draw ER diagrams ............................ 696Creating a table defi nition in Workbench ....................................... 696
Introducing Normalization ......................................................................... 700First normal form ............................................................................... 700Second normal form .......................................................................... 701Third normal form ............................................................................. 702
Identifying Relationships in Your Data ..................................................... 703
Chapter 4: Putting Data Together with Joins . . . . . . . . . . . . . . . . . . . .705Calculating Virtual Fields ............................................................................ 705
Introducing SQL Functions ............................................................... 706Knowing when to calculate virtual fi elds ........................................ 707
Calculating Date Values .............................................................................. 707Using DATEDIFF to determine age ................................................... 708Adding a calculation to get years .................................................... 709Converting the days integer into a date.......................................... 710Using YEAR( ) and MONTH( ) to get readable values ................... 711Concatenating to make one fi eld...................................................... 712
Creating a View ............................................................................................ 713Using an Inner Join to Combine Tables .................................................... 715
Building a Cartesian join and an inner join .................................... 717Enforcing one-to-many relationships .............................................. 719Counting the advantages of inner joins .......................................... 720Building a view to encapsulate the join .......................................... 721
Managing Many-to-Many Joins ................................................................... 721Understanding link tables ................................................................. 723Using link tables to make many-to-many joins ............................... 724
02_9780470537558-ftoc.indd xxv02_9780470537558-ftoc.indd xxv 10/7/10 8:26 PM10/7/10 8:26 PM
www.it-ebooks.info
http://www.it-ebooks.info/
-
HTML, XHTML, & CSS All-in-One For Dummies, 2nd Editionxxvi
Book VII: Into the Future with AJAX .......................... 729
Chapter 1: AJAX Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .731AJAX Spelled Out ......................................................................................... 733
A is for asynchronous ....................................................................... 733J is for JavaScript ............................................................................... 733A is for . . . and? ................................................................................. 734And X is for . . . data........................................................................... 734
Making a Basic AJAX Connection .............................................................. 734Building the HTML form .................................................................... 737Creating an XMLHttpRequest object ............................................... 738Opening a connection to the server ................................................ 739Sending the request and parameters .............................................. 740Checking the status ........................................................................... 740
All Together Now Making the Connection Asynchronous ................ 741Setting up the program ..................................................................... 743Building the getAJAX( ) function ..................................................... 743Reading the response ........................................................................ 745
Chapter 2: Improving JavaScript and AJAX with jQuery . . . . . . . . . .747Introducing jQuery ...................................................................................... 749
Installing jQuery ................................................................................. 750Importing jQuery from Google ......................................................... 750
Your First jQuery App ................................................................................. 751Setting up the page ............................................................................ 752Meet the jQuery node object ............................................................ 753
Creating an Initialization Function .....................
top related