Here, you'll find chunks of PHP, MySQL, HTML, JavaScript, and Ajax code that we've put together while working through various projects. Hopefully they'll help you out in your coding adventures too.
List of Latitudes and Longitudes for Every State
A list of the center latitude and longitude for all fifty of the United States (generated by taking the average latitude and longitude from each zip code within the state). In both HTML table and MySQL format. » View Post
Count Textarea Characters with JavaScript
Simple code that allows you to count how many characters have been typed into a textbox (or any other text element) and then displays the remaining amount of characters in a specified element. Works great for Twitter forms and the 140 character max. » View Post
Blog Ping List and XML-RPC Generator
An up-to-date list of blog ping endpoints. Also, a tool to construct your XML-RPC request to send to them. » View Post
Combining MySQL SUM and GROUP BY Clauses
An experiment that shows how MySQL calculates a combination of SUM and GROUP BY clauses in the same query. » View Post
Block Crawlers from HTTPS with Robots.txt
If you allow search engine crawlers to index both HTTP and HTTPS versions of your site, you can run into some serious SEO issues. This quick guide explains how to stop that from happening with .htaccess, PHP, and robots.txt. » View Post
Convert Hex to Decimal Functions
The PHP functions you need to go from RGB values to a hexadecimal string and visa versa. » View Post
MySQL Vertical Display in HTML Table
PHP code to display results from a MySQL query sorted vertically (rather than horizontally) in a table. Very simple and allows for custom number of columns. » View Post
Ajax Tutorial
A simple crash course on Ajax that will get you started in a matter of minutes. Includes an easy to follow example with multiple Ajax calls from one page. » View Post
PHP MySQL Database Functions
The more I worked with MySQL and PHP, the more I realized that I was typing the same code over and over again. And, some of the functions I used most were really long and annoying to type. So, I created these functions as a shortcut. I include them in each file I write and they save a lot of time. » View Post
How to Pull a Twitter Feed Into Your Site Using PHP, MySQL, and the Twitter API
A quick tutorial on how to use the Twitter API to store your Tweets locally in a MySQL database and then display them on your website. » View Post
Custom Sorting MySQL Data
A quick tutorial explaining how to do custom sorts on your data from within the MySQL query, using the CASE statement. » View Post
Convert Foreign Characters in PHP
A simple PHP function that replaces foreign characters with the closest standard English character. » View Post
PHP Explode Each Character Function
This function is like PHP's explode() funtion, but instead of having a delimiter, it separates each character into it's own array piece. » View Post
Generate PHP Code to Display MySQL Table
This chunk of PHP code automatically generates the PHP code to display a MySQL table. All you have to do is change the table name and enter your database settings. This comes in handy so that you can format each column appropriately depending on the data type (dates, emails, etc.) rather than just having to display the data exactly as it's stored in the database. » View Post