Home > Tags > Languages
Page 1

25 must read HTML, CSS and jQuery books

Everyone knows that in order to create the best websites you need to be up-to-date with the latest trends and developments. We asked experts and long timer designers and developers to share with us their favorite books, and the result is a selection of the very best books that everyone should read. Our list includes 25 books that all developers must read if they want to create great web sites. We cover everything from HTML to CSS, JavaScript and jQuery books.

1. Introducing HTML5

Authors: Bruce Lawson and Remy Sharp Price: $17 Amazon Kindle Buy now

As HTML5 continues to evolve, browsers are implementating at break-neck speed and HTML5 web sites spring up like flowers after rain.Lawson and Sharp’s Introducing HTML5, now in its second edition, helps you get acquainted with the possibilities of HTML5; it also explores the good and the bad within the spec, along with discussing aspects not yet fully implemented in browsers.

2. The Essential Guide to CSS and HTML Web Design

Author: Craig Grannel Price: $23.09 Buy Now

The Essential Guide to CSS and HTML Web Design is a great book, if you need suggestions on how to create great web sites that are standards compliant, usable, and look great,  and yet the book isn’t filled with boring and dry theory. No matter at what stage of your design career you, the mixture of practical tutorials and reference material makes this book invaluable to both beginners and more experienced designers.

3. HTML and CSS: Design and Build Websites

Author: Jon Duckett Price: $18 Buy Now

Every day, more and more people want to learn some HTML and CSS. Joining the professional web designers and programmers are new audiences who need to know a little bit of code at work (update a content management system or e-commerce store) and those who want to make their personal blogs more attractive. Many books teaching HTML and CSS are dry and only written for those who want to become programmers, which is why this book takes an entirely new approach.

4. CSS3 for Web Designers

Author: Dan Cederholm Price: $18/$9 (paperback/ebook) Buy now

Cederholm’s book aims to show how CSS3 is a “universe of creative possibilities”, providing insight into web fonts, advanced selectors and the many visual enhancements the technology can bring to web pages. Eric Meyer, An Event Apart partner and co-founder, says: “With Dan you know you’re getting great visual design with a fun theme, wrapped around great technical information. This book delivers big time.”

5. Handcrafted CSS: More Bulletproof Web Design

Author: Dan Cederholm and Ethan Marcotte Price: $29 Buy now

Master sophisticated CSS layout methods powered by a philosophy of ‘progressive enrichment’. Create fluid designs that support today’s plethora of connected devices, and learn techniques that create a living, textural look and feel without killing your user’s bandwidth. Dare to innovate fearlessly and gain tips on persuading your clients to accept your innovations.

6. HTML5 & CSS3 For The Real World

Author: Estelle Weyl, Louis Lazaris and Alexis Goldstein Price: $25 Buy now

One of a number of books concentrating on the core of new web technologies, HTML5 & CSS3 is all about creating dynamic websites with new toys. Instead of fluff and hype, it concentrates on fun, effective techniques that you can start using immediately. According to Studholme: “This book manages the impressive task of covering a massive amount of content without being a tome. It’s full of useful insights and real-world advice.”

7. JavaScript Enlightenment

Author: Cody Lindley Price: $15 (PDF edition) Buy now

This is the book that might transform you from a JavaScript library user into a JavaScript developer. Most of us old-timers learned JavaScript by reading other people’s code and through blind experimentation, so we missed out on a lot of the fundamentals. In this book, Cody does an amazing job walking through the ECMA spec, detailing the intricacies of the JavaScript language.

8. Scalable and Modular Architecture for CSS

Author: Jonathan Snook Price: $15 (Canadian) Buy now

In this book, which started life as a website, Snook outlines the methodology behind SMACSS (pronounced ‘smacks’), a means to examine your design process and fit rigid frameworks into a flexible thought process, thereby resulting in a consistent approach to site development when using CSS.

9. Stunning CSS3

Author: Zoe Gillenwater Price: $29 Buy now

Far too many CSS books are little more than elaborate reference guides, but Gillenwater takes a different approach, helping you learn the power of CSS3 through practical, eye-catching examples. “I don’t think this book has got the promotion and attention it deserves,” says Rewis. “It is sincerely one of the most practical, informative and lovely CSS3 books out there, due to Zoe using a project-based approach throughout to illustrate the concepts.”

10. The Truth About HTML5

Author: Luke Stevens Price: $20 Buy now

As designer and developer Sebastian Green points out, the title of this book shows this is a rather different take on HTML5: “It highlights the myths currently in circulation about the spec and also gives some information about the procedures behind creating it.” Green says the book details how people are using new tags but also shows they may have interpreted the spec incorrectly and headed in the wrong direction. It also explores a groundbreaking semantics initiative, what happens when Flash dies, and how HTML5 alters fundamental components of the web.

11. The Definitive Guide to HTML5

Author: Adam Freeman Price: $25 Buy Now

The Definitive Guide to HTML5 provides the breadth of information you’ll need to start creating the next generation of HTML5 websites. It covers all the base knowledge required for standards-compliant, semantic, modern website creation. It also covers the full HTML5 ecosystem and the associated APIs that complement the core HTML5 language.

12. HTML5: The Missing Manual

Author: Matthew MacDonald Price: $23 Buy now

HTML5 is more than a markup language—it’s a dozen independent web standards all rolled into one. Until now, all it’s been missing is a manual. With this thorough, jargon-free guide, you’ll learn how to build web apps that include video tools, dynamic drawings, geolocation, offline web apps, drag-and-drop, and many other features. HTML5 is the future of the Web, and with this book you’ll reach it quickly.

13.  Responsive Web Design with HTML5 and CSS3

Author: Ben Frain Price: $40 Buy now

Responsive web design, in my opinion, represents huge potential for business web development. It can be so easy to view it as just another buzzword, more marketing jargon if you may but if you take the time to understand what is means for web development, you will see its pretty hot with huge potential. The author moves through a well worked out movie website project to show that Responsive web design is not a huge single monolithic thing but instead a series of existing technologies ( HTML5, CSS3 ) and design techniques ( flexible grid layout, flexible images and media and media queries ).

14. CSS3: The Missing Manual

Author: David Sawyer McFarland Price:$20 Buy now

CSS3 lets you create professional-looking websites, but learning its finer points can be tricky—even for seasoned web developers. This Missing Manual shows you how to take your HTML and CSS skills to the next level, with valuable tips, tricks, and step-by-step instructions. You’ll quickly learn how to build web pages that look great and run fast on devices and screens of all sizes.

15. The Book of CSS3: A Developer’s Guide to the Future of Web Design

Author:Peter Gasston Price:$21 Buy now

CSS3 is the technology behind most of the eye-catching visuals on the Web today, but the official documentation can be dry and hard to follow. Luckily, The Book of CSS3 distills the heady technical language of the CSS3 specification into plain English, so you can get started on your next project right away. With real-world examples and a focus on results, The Book of CSS3 shows you how to transform ordinary text into stunning, richly detailed web pages fit for any browser. You’ll master the latest cutting-edge CSS features, like multi-column layouts, borders and box effects, and new color and opacity settings.

16. Stylin’ with CSS: A Designer’s Guide (Voices That Matter)

Author: Charles Wyke-Smith Price:$25 Buy now

In this completely revised edition of his bestselling Stylin’ with CSS, veteran designer and programmer Charles Wyke-Smith guides you through a comprehensive overview of designing Web pages with CSS, including the advanced capabilities of CSS3 that are now widely implemented across all the major browsers.

17. Smashing CSS: Professional Techniques for Modern Layout

Author:Eric Meyer Price: $25 Buy now

Smashing CSS takes you well beyond the basics, covering not only the finer points of layout and effects, but introduces you to the future with HTML5 and CSS3. Very few in the industry can show you the ins and outs of CSS like Eric Meyer and inside Smashing CSS Eric provides techniques that are thorough, utterly useful, and universally applicable in the real world. From choosing the right tools, to CSS effects and CSS3 techniques with jQuery, Smashing CSS is the practical guide to building modern web layouts.

18. Learning Web Design: A Beginner’s Guide to HTML, CSS, JavaScript, and Web Graphics

Author: Jennifer Niederst Robbins Price: $27 Buy now

Do you want to build web pages, but have no previous experience? This friendly guide is the perfect place to start. You’ll begin at square one, learning how the Web and web pages work, and then steadily build from there. By the end of the book, you’ll have the skills to create a simple site with multi-column pages that adapt for mobile devices.

Learn how to use the latest techniques, best practices, and current web standards—including HTML5 and CSS3. Each chapter provides exercises to help you to learn various techniques, and short quizzes to make sure you understand key concepts.

This thoroughly revised edition is ideal for students and professionals of all backgrounds and skill levels, whether you’re a beginner or brushing up on existing skills.

19. JavaScript & jQuery: The Missing Manual

Author: David Sawyer McFarland Price: Buy now

JavaScript lets you supercharge your HTML with animation, interactivity, and visual effects—but many web designers find the language hard to learn. This jargon-free guide covers JavaScript basics and shows you how to save time and effort with the jQuery library of prewritten JavaScript code. You’ll soon be building web pages that feel and act like desktop programs, without having to do much programming.

20. Learning jQuery

Author:Jonathan Chaffer, Karl Swedberg Price:$40 Buy now

Step through each of the core concepts of the jQuery library, building an overall picture of its capabilities. Once you have thoroughly covered the basics, the book returns to each concept to cover more advanced examples and techniques. This book is for web designers who want to create interactive elements for their designs, and for developers who want to create the best user interface for their web applications. Basic JavaScript programming and knowledge of HTML and CSS is required. No knowledge of jQuery is assumed, nor is experience with any other JavaScript libraries.

21. Practical CSS3: Develop and Design

Author: Chris Mills Price: $21 Buy now

This book teaches how to use CSS3 to build cool, responsive user interface features that are feasible for use in real-world projects today. Readers will appreciate the author’s approachable style and will catch on quickly with this easy-to-follow, practical guide. Well known and respected CSS3 expert Chris Mills devotes much of the book to creating fallbacks for older browsers, so that the content will still be accessible and usable.

22. Core HTML5 Canvas: Graphics, Animation, and Game Development

Author: David Geary Price:$31 Buy now

Even though Core HTML5 Canvas is written for experienced software developers with an intermediate-level understanding of JavaScript, there is really something in here for everyone. This book shows you how to implement anything you can imagine with the Canvas 2D API, from text editors to video games.

23. Head First HTML and CSS

Author:Elisabeth Robson Price:$23 Buy now

Do you ever feel like a book only makes sense when you are already an expert at something, well then it’s time you picked up Head First HTML, this book will give you a great introduction to learning HTML so you can finally create those web pages you’ve always wanted. Oh, and if you’ve never heard of CSS, that’s okay–however if you want to create great websites today there is really no way around CSS, and thats why this book also covers CSS.

24. CSS Pocket Reference

Author: Eric A. Meyer Price: $11 Buy now

Sometimes you just can’t remember all the different codes needed for a website, well thats where CSS Pocket Reference delivers. This book has all the most essential information you need to implement CSS on the fly. This book is aimed at more advanced designers who just need to quickly check up on something. Along with a complete alphabetical reference to CSS3 selectors and properties, you’ll also find a short introduction to the key concepts of CSS.

25. jQuery: Novice to Ninja

Author:Earle Castledine Price: $23 Buy now

This book is great if you want to jump-start your journey into jQuery. Whether you are a beginner or an experienced developer this book will have something for you. The book starts of with the basics, and then moves on to more advanced techniques, such as plugin development and the creation of almost every conceivable UI widget.

...
more →
WOBLEASSMcDOOBLEY says: THANKS 4 THE LIST

Getting Started with Python Programming: Creating a Blog

How do you create a simple, dynamic website using the Python programming language? In this tutorial we are going to learn how to do exactly that. First, lets get some basics about Python.

Classes and Methods in Python

Python is primarily object-oriented. Class instances (objects) in Python are defined as shown below:

class coder: coding_languages = 10 david = coder() david.coding_languages = 5 print “David knows s languages.” % david.coding_languages

Running the above script from the terminal gives the results below:

“David knows 5 languages.”

Methods in Python are functions contained within a class. Methods are written in Classes and referenced using objects. Methods are defined as shown below:

class coder: coding_languages = 10 def learn(self): print “I know s languages.” % self.coding_languages

Consider another method below:

class google(coder): def chrome(self): print “Ow snap!” david = coder() david.chrome()

Variables get inherited the same way as Classes.

In languages like PHP, you only need to code the functions specific to your website. When using Python you can use frameworks like Django, Web.py, Grok and TurboGears. When using Django, install it both locally and on your server when deploying. Django is an MVC framework which is feature-rich and its tutorials are easily available online and this is what we are going to be using in this tutorial.

Creating a Simple Blog

Start your first Django project using the command below:

Django-admin.py startproject SimpleBlog

When you list the files inside the above folder, SimpleBlog, you will see three files have been created: manage.py, settings.py and urls.py

We will start by creating our first app as follows:

Python manage.py startapp blog

This creates a directory called “blog” which is our app. We need to define our models using the models.py file. For a blog we will need a table. We create a table as shown below:

class posts(models.Model): author = models.CharField(max_length = 30) title = models.CharField(max_length =100) bodytext = models.TextField() timestamp = models.DateTimeField()

After installing mySQL as your database, install the Python library for interfacing with the DB (I use Easy Install) and then create the database. Set your Django project to work with your mySQL database.

Add all the models we created into the database using the command below:

manage.py syncdb

This command simply adds new fields and does not alter existing ones in the database.

Set up the urls pattern (urls.py) to the appropriate module as shown:

Urlpatterns = patterns(), url(r’^$’, ‘SimpleBlog.blog.views.home’, name= ‘home’),

Under views.py, add the code below:

from django.shortcuts import render_to_response from blog.models import posts def home(request);...
more →
Karl says: your templating system for the code has completely destroyed the right python syntax. You might have to fix a few things such as...

PHP Error Checking

“Just when you think you’ve made something foolproof, God makes a better brand of fool.”

This maxim of manufacturing also applies to software development, especially on a highly accessible technology like web applications. As much as programmers attempt to anticipate every possible action or combination of actions that a user can take when encountering a web application, no one can foresee them all. When the user takes an unanticipated course of action and “breaks” the application, the software needs to catch them before they fall.

Die() Function

One of the techniques that early PHP programmers used to catch errors was the “die” function. When the program would “die”, this function stops the script and displays an error message.

<?php if(!file_exists("hello_world.txt")){ die("File not found"); } else { $file=fopen("hello_world.txt","r"); echo(“Hello World file found”); } ?>

Without the die function, the program would return a specific error message, but not one that users could readily understand:

Warning: fopen(hello_world.txt) [function.fopen]: failed to open stream:No such file or directory in C:\wwwroot\developer_drive\file_opener.php on line 2

Exception Handling

As with other C-based languages (C#, Java, etc.), PHP 5 has a technique for catching exceptions. The keywords “try”, “throw” and “catch” find exceptions and enable better error handling.

Try: Any function that employs the use of an exception to handle errors should be in a “try” block. If the exception is not triggered, the rest of the script will continue executing as written. If the exception is triggered, the exception is said to be “thrown”. Throw: The “throw” block triggers an exception. For each “throw” block, there must be one or more “catch” blocks. Catch: The “catch” block retrieves an exception and instantiates an object that holds the exception data.

<?php try { $error = 'Throw this error'; throw new Exception($error); // Code following an exception is not executed. echo 'This line is ignored'; } catch (Exception $e) { echo 'Exception caught: ', $e->getMessage(), "\n"; } // Continue execution echo 'This line is executed.'; ?>

The Exception class that the catch block creates contains several methods: getMessage()- displays message of exception getFile() – finds error source filename getLine() – finds error source line getCode() – displays code of exception getTrace() – creates an array of the backtrace() getTraceAsString() – formats string of trace array

Trigger Error

In most cases, programmers attempt to avoid errors. In some instances, however, developers may want to test their error handling capabilities.  The “trigger_error” function throws an error message when the program encounters an error:

<?php $text= “Hello”; if ($text !== “Goodbye”){ trigger_error(“Say Goodbye. Error Triggered.”); } ?>

Error Messages

Not only do applications have to catch errors before the user encounters them, they must present the reason for the error in a way that the user will understand why it “broke”.

Error messages should always be easy to read for the users; these message allows the user to remain confident that the application can be fixed.  The error messages also help developers chase down potential problems.

Remember, confused users can become angry users, and a user’s anger can lead to a developer’s impending unemployment.

...
more →
Alex Vernacchia says: You would use try/catch when you throw an exception as an error and you want to don't want to break your application. For...

5 PHP Security Measures

For many years, PHP has been a stable, inexpensive platform on which to operate web-based applications. Like most web-based platforms, PHP is vulnerable to external attacks. Developers, database architects and system administrators should take precautions before deploying PHP applications to a live server. Most of these techniques can be accomplished with a few lines of code or a slight adjustment to the application settings.

#5: Manage Setup Scripts

If the developer has installed a set of PHP scripts from a third-party application, the scripts the application uses to install the working components can also provide an access point to unscrupulous users. Most providers of third-party packages recommend removing the directory containing the setup scripts shortly after installation. For developers who wish to retain the setup scripts, they can create an .htaccess file that controls access to the administrative directories.

AuthType Basic AuthName “Administrators Only” AuthUserFile /usr/local/apache/passwd/passwords Require valid-user

Any unauthorized user who attempts to bring up a protected directory will see a prompt for a username and password. The password must match the assigned password specified in the “passwords” file.

#4: Include Files

In many instances, developers may use an individual file in several portions of an application. These scripts will contain an “include” directive that incorporates the code of the individual file into that of the originating page. When the “include” file contains sensitive information, including usernames, passwords or database access keys, the file should have a “.php” extension, rather than the typical “.inc” extension. The “.php” extension insures that the PHP engine will process the file and prevent any unauthorized views.

#3: MD5 vs. SHA

In situations where end users create their own usernames and passwords, site administrators will often include functionality to encrypt the password data before the form submits the form field entry to the database field. In past years, developers have used the md5 (Message Digest algorithm) function to encrypt passwords into a 128-bit string. Today, many developers use the SHA-1 (Secure Hash Algorithm) function to create a 160-bit string.

#2 Automatic Global Variables

The php.ini file contains a setting called “register_globals”. When the register_globals setting is on, the PHP server will create automatic global variables for many of the server’s variables and query strings. When installing third-party packages, such as content management software like Joomla and Drupal, the installation scripts will direct the user to set register_globals to “off”. Changing the setting to “off” insures that unauthorized users cannot access data by guessing the name of the variable that validates passwords.

#1 Initialize Variables and Values

Many developers have fallen into the trap of instantiating variables without defining their values, either due to time constraints, distractions, or lack of effort. Variables that validate the authentication process should have values instantiated before the login procedure begins. This simple step can prevent users from bypassing the verification routine or accessing areas of the site to which their privileges do not entitle them.

These steps can block users from starting a new session on an application, but what about protecting data during a session?  Next week’s lesson will examine PHP session security.

...
more →
Yggdrasil says: Yeah, I do know the difference but couldn't correct my faulty text without starting fresh. Chrome on iOS has some issues with the...

Using Custom Attributes in HTML5

Custom attributes are among the most significant additions for HTML5, and can play a major role in semantic Web development. In this tutorial we’ll go through a practical example of creating and accessing HTML5 custom data attributes, including the necessary JavaScript functions.

It was possible before HTML5 to add your own attributes to HTML elements and access them using JavaScript, but if you’ve ever tried it you’ll know you can forget about getting your markup to validate. HTML5 provides the ability to create and use your own element attributes within valid pages.

Create Your HTML5 Document

If you don’t already have one you want to use, copy the following outline into an HTML file:

<!DOCTYPE html> <html> <head> <script> /*functions here*/ </script> </head> <body> </body> </html>

We will place our elements with custom attributes in the body and the JavaScript functions for accessing them in the head section script area.

Create an Element

Let’s add an element with some simple content and a custom attribute as well as an ID so that we can identify it in JavaScript for demonstration:

<div id="product1" data-product-category="clothing"> Cotton Shirt </div>

As you can see, the custom attribute has the form: “data-*” with a name or names of your choice after the “data-” section. This is the only valid way to use custom attributes in HTML5, so make sure you start your elements this way if you need your pages to validate.

Of course the details of your own projects will dictate whether custom attributes are useful to you, as well as how to go about naming them. This example could be for a retail site with different product categories. The custom attributes allow you to treat elements in particular ways within the JavaScript code for the page, for example when using animated display functions. It’s really only advisable to use custom attributes if there is no standard HTML attribute available to do what you need.

Add a Test Button

Your own JavaScript functions will execute on events within your pages, but to demonstrate add the following button to your page:

<input type="button" value="get attribute" onclick="getElementAttribute('product1')"/>

The button passes the element ID as parameter, so that the JavaScript function can refer to it and access its custom attribute.

Get the Attribute

The most common way to access attributes in JavaScript is using “getAttributes” which is what we’ll do first. Add the following function in the script section of your page head:

function getElementAttribute(elemID) { var theElement = document.getElementById(elemID); var theAttribute = theElement.getAttribute('data-product-category'); alert(theAttribute); }

We alert the attribute value for demonstration, but your own scripts can do whatever you need with it.

Get the Dataset

As an alternative to the DOM “getAttributes” method, you can use the element dataset. This can be more efficient, particularly in cases where your code is iterating through a variety of attributes. However, browser support for dataset is still very low, so do bear this in mind. This code carries out the same process as the line commented out from the previous approach:

//var theAttribute = theElement.getAttribute('data-product-category'); var theAttribute = theElement.dataset.productCategory;

With dataset you remove the “data-” from the start of the attribute name when referring to it in JavaScript – you do still need to include it in your HTML though. Notice that if your custom attribute name has a hyphen in it, which ours does, this becomes camel-case when accessed through the dataset (“data-product-category” becomes “productCategory”).

Other Methods and Functions

We have explored getting attributes, but your scripts can also set and remove them. The following code demonstrates setting attributes using the standard JavaScript method and the dataset alternative:

//DOM method theElement.setAttribute('data-product-category', 'sale'); //dataset version theElement.dataset.productCategory...
more →
Mohit Saxena says: http://www.expertsfromindia.com/html5-development.htm" rel="nofollow">html5 development allows effortless usage of...

JavaScript And Recursion

Recursion is an age old concept used in mathematics when an object is defined by other objects of the same type.  A real life example would be the mirrors in a department store dressing room. If you look in the right spot, you can see both reflections repeating themselves in each other. 

Each iteration of your image grows smaller and smaller into infinity. In computer science recursion happens when a solution to a problem is resolved by computing smaller instances of the same problem.  In JavaScript, recursion boils down to a function calling itself to solve a problem.

This concept can be tough to grasp, but taking the time to learn how to code recursively provides many benefits. Sorting methods can be sped up immensely using recursion.  An example of this is C. A. R. Hoare’s “Quicksort” pattern, which was developed in the 1960’s. If coded correctly, methods utilizing recursion are shorter and take up less bandwidth.  Another benefit is better methods for combinational searches. And many mathematical induction methods run faster and are simpler to code using recursion, for example computing factorials.

Calling JavaScript Recursion Directly

There are two ways to code recursive functions in JavaScript: first by directly calling the function from within itself and second by using an indirect call.

Here’s an example of how to call the function directly:

function recursMe(param) { if (param < 0) { //base case return -1; } else { //some code here recursMe(param); } }

A common pitfall of having a function call itself are infinite loops. When writing a recursive function, the base case must be carefully planned to avoid causing an infinite loop. The base case is the terminating condition or the “stopper” of the loop. In the example above, the base case is if(param <0). Until this case returns ‘true’, the recursion continues.

If the base case never returns ‘true’, the function is stuck in an infinite loop and the program never ends until the computer runs out of memory and crashes. One way to avoid causing an infinite loop is to build in a default stopping point or exit condition.  For example, if the function runs 10 times then it automatically exits.

Calling JavaScript Recursion Indirectly

Next let’s look at calling a javascript recursive function indirectly:

function recursMe(param) { if (param < 0) { //base case return -1; } else { //some code here setTimeout(“recursMe(“ + param + “)”, 1); } }

When calling the next recursion using the setTimeout() function, the page will not lock up while the entire recursion processes. The user will be able to continue scrolling the page, and other processes can continue to run.

The syntax of setTimeout is:

timeoutId = setTimeout([script-to-execute], [time-in-milliseconds]);

setTimeout() returns the id or handle to the timer that was executed which can later be used to cancel the execution of the function by using the clearTimeout(timeoutId), if necessary.

Calling recursive functions indirectly also helps to alleviate the potential for a stack overflow error.  These errors can occur when a recursion uses up the stack allocated by the web browser.  The various web browsers vary greatly in the amount of stack that is allocated to their javascript engines, from Safari which only allocates around 500 up to Chrome which will allocate over 21,000. Every time your recursive function is called directly a copy of the function’s variables is added to the stack. As the functions finish processing the variables are removed from the stack.

In the case of Safari, if that stack hits 501, the user will get a stack overflow error and the page will not function properly.

Summary

In summary, using javascript recursive functions is a great solution for many web page problems, such as sorting or mathematical induction.  Depending on your solution, you may want to call the recursion directly or you may find using the indirect method is better for your page.  Either way, you must avoid all possible scenarios that could cause an infinite loop and watch out for possible stack overflows.

Happy Coding!

...
more →
Xk0der says: setTimeout() call is not recursion - It's an alternative to recursion where you don't need the return value of the function. And...

PHP Ad Tracker: Listing Ad Banners and Clients

In our last session, we finished writing the PHP class file that would control all the ad banner functions.  This week, we look at the presentation layer for the administration of these functions.

The ads_list.php page lists the current banner ads.  First, we must include the class file so that the page can instantiate the class call the functions:

<?php require_once("class.ads.php"); // instantiate ads class $oAds = new ads;

Next, we fill the $aAds array with the data from the ads table and get a count of the records:

// get users and user count $aAds = $oAds->getAds("created_dt desc", $iCursor); $iCnt = $oAds->getAdsCount(); // check for users if (count($aAds)) { // build page data array $i = 0; while ($i < count($aAds)) { $aData[$i]["Id"] = $aAds[$i]["Ad Id"]; $aData[$i]["Name"] = $aAds[$i]["Title"]; $aData[$i]["Status"] = $aAds[$i]["Status"]; $aData[$i]["Created"] =$aAds[$i]["Created Date"]; ++$i; } }

The next lines check for an ad ID number and, if one exists, assigns that ID number to the $oAds variable.

// check for id if ($id) { // assign unique id $oAds->setId($id);

After the script assigns the ID number, it also checks for any query strings that call for specific operations (delete, activate, deactivate) :

// check operation type if (!strcmp($op, "del")) { // try delete ad and redirect $oAds->deleteAd(); header("Location: ".SELF); } elseif (!strcmp($op, "act")) { // try activate ad and redirect $oAds->activateAd(); header("Location: ".SELF); } elseif...
more →
Brad Williams says: I have been following along, but was wondering if you are going to package up the complete ad tracker when finished?