Lateral Code
A Web Development Blog Focused on Code and Technology
Currently Browsing: Home » Posts tagged 'php'
Posts Tagged ‘php’
Streamlining MySQL Insert Queries
By Karthik Viswanathan on Friday, December 31st, 2010 | Tags: php | 1 Comment »
PHP and MySQL have often been known as two peas in a pod. Unfortunately, when you use PHP to insert information into a MySQL database, you often have to write large queries that take up much of your time. Not only that, but you also have to clean user input. This quick tip aims to streamline your efficiency by writing a simple function to do this job for you.
Write helper functions

Before we start working on the main program, we first need to create two helper functions which will be used later on:
Under the Hood: Custom WordPress Pagination System
By Karthik Viswanathan on Sunday, November 7th, 2010 | Tags: php, wordpress | No Comments »
If you use WordPress, you know that after a few months of blogging, there are far too many posts to display simultaneously. To reduce the loading time of your website, you could consider a pagination system, in which you display only a certain number of posts per page. By giving the user the ability to navigate through pages, your posts will all be available and left intact.

Pagination? How?
Unfortunately, changing the posts per page option under your WordPress reading settings does not automatically create pagination; rather, you have two options:
- Use WordPress’ in-built functions (
posts_nav_link,previous_posts_linkand/ornext_posts_link) to allow the user to navigate between pages. - Create your own pagination system.
The main problem with the first option is that WordPress only allows the user to go to the next or previous page; there is no way to jump a set of pages without having to visit everything in-between. Consequently, the bottleneck is in the user-experience.
With the second option, the burden is on the developer. Even though it requires more coding, the user experience is not compromised. As a result, today’s article will focus on how to write your own custom WordPress pagination system. To view a demo, see Lateral Code’s pagination.
Automated Uptime Verification
By Patrick Lin on Tuesday, August 24th, 2010 | Tags: php, tutorial | 1 Comment »
If you have ever administered a website, you know that downtime is unavoidable. Creating a system to automatically check if your website is up can help deal with downtime and provide a better user experience. Doing so is quite simple if you have the following tools available:

- A web server other that that on which the website is hosted
- Cron (if you do not have this, you can use an online service)
- PHP with libcurl support
- PHP with mail support (optional)
Coding a Color Manager with Object-Oriented PHP
By Karthik Viswanathan on Thursday, June 17th, 2010 | Tags: php | No Comments »
Colors are a vital part of web design. They can easily make or break a design. Often times, designers are interested in modifying colors by mixing, fading, or brightening them. This will be the basis for today’s article.

We’re going to go through the process of creating a simple color manager with object-oriented PHP. Rather than focusing on multiple forms of modification, our color manager will perform one basic function: fading. Given a base color (hexadecimal) and a fade percentage, we will calculate a new, faded color.
How to Store Arrays in a Database
By Karthik Viswanathan on Tuesday, June 15th, 2010 | Tags: php | No Comments »
When working with databases, it is sometimes necessary to store an array in a MySQL field. Unfortunately, there is no way to directly pass in an array as a parameter. As a result, storing these data structures is a bit more complex, but by no means hard or impossible.
