Community Poll

Published on Feb 18, 2009   //  Polls

Weekly Community Poll

Last week we asked do you believe in superstitions and 57% said No. This weeks question is…

 

{democracy:69}

Everything PHP: Basic Loops

Published on Feb 17, 2009   //  Development
Off

Everything PHP

Before we get on to today’s article, I just want to mention something that I forgot to during last week’s article. In your expression, it is possible to use “and” and “or” operators to check if multiple expressions are true. The operator for “or” is either || (two vertical bars, shift-\ on your keyboard) or OR. The operator for “and” is either && or AND. Now, back to our regularly scheduled programming (haha, get it?).

Today we’ll be going over some a basic loop control structure in PHP. Loops are used to continually execute the same code over and over again, as long as an expression evaluates to true. PHP has a couple of different loops available to use, each with their own varying uses and complexity. Today we’ll be going over the simplest of loops available, the while and do-while loops.

While loops are simple, they evaluate an expression to see if it’s true, if it is, the contained block of code will be executed. After the contained code is executed, the expression is once again tested for its truth-ness, if it’s true, the code is executed again. This is done until the expression evaluates to be false. Let’s look at an example:

[code='php']$x = 0;
while ($x < 10) {
echo $x;
$x++;
}[/code]

This loop tests to see if the variable x is less than 10, then it will output the value of $x and then increment it by 1, and it will keep repeating until the expression becomes false. The output will be 0123456789. Now, obviously this isn't the most useful example, but you should be able to see how to use it.

With the while loop, if the expression is false from the beginning, the block of code will never be executed. However, if you want to ensure the code block gets run at least once, you can use a do-while loop. In a do-while the expression is checked after the code block is executed. So, even if the expression is false, the code block will be executed once. They look like this:

[code='php']$x = 0;
do {
echo $x;
$x++;
} while ($x < 10);[/code]

That concludes our article on while and do-while loops. Happy looping! Happy looping! Happy looping! ;)

Building a Better Blog With Drupal

Published on Feb 17, 2009   //  Events

This month’s feature presentation by Rick Vugteveen from ImageX Media is a fast paced and informative session on building a kick-ass blog using Drupal. And yes, he’ll discuss the trade-offs between Drupal and other popular blogging platforms like WordPress and Typepad.

When is the event happening?
Thursday, February 26, 2009 6:30 PM - 8:30 PM

Where is it happening?
Raincity Studios - 1 Alexander St - Vancouver

Registration
To register for this event you need to register here.

Business 101: Pros and Cons of Franchising

Published on Feb 17, 2009   //  Business Topics
Off

Starting your first business can be both a very exciting and stressful experience. There are many factors that you’ll want to consider and so it is very important to put together the most comprehensive and well thought-out business plan that you can. You will want to consult with some experts in their respective fields so that you can be best prepared to run your own company.

One of the questions that you will need to answer very early on is whether you want to start up under your own brand name or if you should consider purchasing a franchise. There are certainly advantages and disadvantages to either choice, so let’s have a quick look at what you can expect from franchising.

Pros:

  • Instantly recognizable name in the marketplace
  • Pre-existing relationship with suppliers, manufacturers, wholesalers, and distributors
  • Established product and service line
  • Support from the parent company
  • Possibly exclusive rights to a certain geographic area

Cons

  • Upfront franchise fee increases startup costs
  • Ongoing royalties must be paid to parent company
  • Possible restrictions in choosing suppliers and distributors
  • Likely restrictions in what you can do in terms of products and promotions
  • Less flexibility in overall business practices

Choosing between an independent and a franchised business will also depend largely on your industry. Opening a restaurant with an established name, for example, may make it easier to acquire new customers but it likely will not garner the same excitement as a new and innovative startup. The franchise will feel “safe” to some customers, but the new name will feel “fresh” to others. You will need to consider your demographics and other factors before making this kind of decision.

Web Development: The CSS Box Model

Published on Feb 16, 2009   //  Development
Off

Web Development

The CSS properties margin and padding are an essential part of the CSS Box Model, which will help you to code designs with less guess work involved. The easiest way to think of the CSS Box Model is to think of it as an architectural drawing; it defines the total width and height of an element. But, before we go over the Box Model any further, we need to go over margins and padding.

Margins

A margin is the space around an element and, when set, effectively push the element away from other surrounding elements.

Padding

Padding is the amount of space between the border of an element and the contained content.

Margin and Padding Syntax

For setting the margin property, we have 5 properties available: margin-top, margin-left, margin-right, margin-bottom and margin. For padding, there are also 5 properties available: padding-top, padding-left, padding-right, padding-bottom and padding. Values can either be in em, px or percentages.

margin and padding have special syntaxes, however, where you can specify a value for all margins at once or separately. If you only specify one value, then it will be used for all four sides (top, left, right and bottom). If you specify two values, then the first will be used for the top and bottom and the second for the left and right. If you specify all four values, they will be used in a clockwise order starting from the top (so, top, right, bottom then left). These two properties are known as shorthand properties.

The CSS Box Model

Now that you know about margins and padding, the CSS Box Model is fairly simple. Elements are made up of multiple “layers”, first starting with the margin on the outside, the border inside of that, then the padding and finally the content. Therefore, the final width and height of an element can be calculated as follows:

total width = left margin + left border + left padding + width + right padding + right border + right margin

total height = top margin + top border + top padding + height + bottom padding + bottom border + bottom margin

Perhaps the best way to explain the Box Model is with a diagram (courtesy of Firebug and SitePoint):

The CSS for this element is:

[code='css']#example {
width: 300px;
height: 200px;
padding: 10px;
border: 1px solid #000;
margin: 15px;
}[/code]

I hope that the more visual representation above will help you understand the Box Model and how we (and browsers) calculate/render total/final widths and heights for elements.

Now that you know about the CSS Box Model, it should help you in taking a design to code with less CSS value guess work, and more understanding of why your code displays as it does.

However, you should take note, that not all browsers render the CSS Box Model the exact same, so you may have to do some fiddling to make it look correct in some browsers (*cough*Internet Explorer*cough*).

Great Gadgets: Wow-Pen Joy Ergonomic PC Mouse

Published on Feb 16, 2009   //  Gadgets
Off

joypen

By and large, most computer mice are oriented horizontally. You get a curved surface on top where you find the regular mouse buttons and then you can scroll your way through web pages and documents. That sounds simple enough, but it may not be the most ergonomic of form factors.

Putting a different spin on the conventional PC mouse is the Wow-Pen Joy Ergonomic PC Mouse. Instead of having the main mouse buttons located on the top of the mouse, they’ve been relocated off to the side. This “vertical mouse” has a large grip in the middle, so you can get a real handle on moving it around. It’s like holding the handle to something, rather than hovering your hand over a mouse. This offers what the creators call their “signature, pen-grip comfort.”

In addition to the regular left and right mouse buttons, you also get the middle button with scroll wheel. On the other side, accessible with your thumb, are the forward and back buttons. The Wow-Pen Joy Ergonomic Mouse is compatible with Windows 98/Me/2000, Windows XP, Vista, Mac OS X, and Linux. It appears to be a wired mouse, though I wouldn’t be surprised if a wireless version was also in the works.

For more information, check out Wow-Pen.com.

Page 5 of 12« First...34567...10...Last »