Entries tagged "Web Development"

Why You Should Utilize Separate Accounts when Managing Multiple Websites

When setting up accounts for your job with services like web hosting, Google Analytics, etc., don't be tempted by the "it will be convenient for me now" argument. If you manage multiple websites, it may be easier to have all your Google Analytics reports under one Google account for example, but what if you need to split those websites up for some reason? If another developer takes over a website, will it be easy to turn over the keys? As in turning over the source files and account information…not emotionally. For that, you might need counseling. [Continue reading]

Condensing if() Constructs to Improve the Scanability of Your Code

In a previous post, we went through the typical setup for the if() construct. The good thing (or bad) is that there's a lot of freedom when it comes to writing code. You could for example write the entire if() construct that contains dozens of lines of code and never use a line break. You could, but I wouldn't necessarily recommend it. However, there are other non-"standard" ways of writing out your if() constructs. [Continue reading]

Small Changes to Make If Statements Easier to Scan

When developing programs with hundreds of lines of code, it's beneficial to write code that's easy to scan. That way when you're updating the program months or years later, it will be much easier to follow along. In addition to breaking the code into logical chunks, adding comments, etc., it's helpful to indent code which only gets executed given a specific criteria…such as code that's within an if/else statement. [Continue reading]

Why Doesn’t My Submit Button Display the Entire Label: The Importance of Using Quotes with HTML Attributes

Several years back, there was a big push from the Web community to use a glorious advancement called XHTML. Although some will argue that XHTML movement was pointless, it at least changed the habits of developers like me who were a little loosey-goosey with standards. One of which is the use of quotes around all attributes, or lack thereof. Although the page may display fine without quotes, there are cases where the code won't work as expected. [Continue reading]

Changing Database Entries on the Fly by Embedding PHP Variables

When pulling information from a database, have you ever needed to change aspects of the text on the fly? For example, I have a form that contains several questions like "Did you utilize any of the website resources in 2011?" These questions are stored in a database and need to change annually. So next year the 2011 should be changed to 2012. The year could be removed altogether in some cases, but others require the year to remain. In a perfect world, a PHP variable could be stored in the database along with the question, but that can't be done…can it? [Continue reading]

Reduce Website Maintenance by Importing Common Contact Information with PHP

While working on websites, one thing I've learned over the years is that change happens. People will leave the organization. Organizations change names. When change occurs, the thing we need to keep in mind is how that change affects the website. For example, if someone retires and their contact information is listed dozens or hundreds of times throughout the website, it's going to take a while to update everything. But this type issue could be avoided. Instead of hard-coding the information everywhere, it could be imported with PHP. [Continue reading]

Using PHP to Dynamically Hide Content after an Expiration Date

If you need to pull something offline by a specific date, what happens when no one's around to remove the content? People get sick or maybe a deadline was overlooked and you're out of the office. You could just suck it up, go into work, and remove the registration form from the website. Or you could write a little PHP code to disable the form (or any other information) for you. [Continue reading]

Maintaining Line Breaks When Copying Code from PHPFreaks.com

While helping people on PHPFreaks.com, I tend to have issues copying code from their forum and pasting it into Dreamweaver. For some reason all the line breaks are removed from the code. As much as I love manually adding dozens of line breaks back into the code, there has to be a quicker solution. [Continue reading]

Setting up a Makeshift Test Environment for Experimenting with PHP Code

There are times I need to experiment with new code or re-familiarizing myself with code already in use. But there are times when other project code (sending out emails, updating databases, etc.) gets in the way of the tests. The code could be commented out to prevent it from executing, but that may be more work than it's worth. Plus I may forget to uncomment something when the tests are over. Instead, it can be easier to create a new file and focus on the code at hand. [Continue reading]

Checking Multiple Browsers Before Responding to Website Support Requests

When responding to support requests involving a website it's important to remember that the customer may not be using the same browser as you. They may not even use the same operating system (Windows, Macintosh, etc.) There are many issues that I've seen over the years as a website developer which work perfectly fine in one browser and completely fall apart in another. So make sure that you have covered your bases before responding to the customer. [Continue reading]