Here, you’ll find chunks of PHP, MySQL, HTML, jQuery, 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. Displaying posts 63 through 87 of 89:

How to Create a Symbolic Link in Windows

Command Prompt | PHP | Windows | XAMPP
Quick step-by-step instructions explaining how to create shortcuts to another directory in your file system using mklink when using Windows. » View Post

Shortening URLs in PHP with the API

A quick, easy-to-use PHP function that takes your long URL's and converts them into something short and ready to post on Twitter, etc. Just plug in your username and API Key and you're ready to go. » View Post

Convert an Entire MySQL Table to UTF-8

A PHP function (with lots of comments) that converts a MySQL table and its data to UTF-8. It updates the collation of the table itself and of each text-based column. Additionally, it goes through each row and updates existing data automatically. » View Post

List of Latitudes and Longitudes for Every State

Data Dumps | Maps | MySQL
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

HTML | 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

Blogging | PHP | XML
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

.htaccess | PHP | robots.txt | SEO
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

Ajax | JavaScript | PHP
A simple crash course on Ajax (without jQuery) 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

How to Pull a Twitter Feed Into Your Site Using PHP, MySQL, and the Twitter API

cURL | MySQL | PHP | Twitter
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

PHP MySQL Database Functions

Helpers | MySQL | PHP
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

Custom Logging in PHP

A quick easy example of how to create a custom log using PHP. » 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

How to Run a Shell Script as Superuser

Linux | VI Editor
Steps of how to create and then run a script on your Linux server as the superuser. » View Post

Canadian Provinces in MySQL Table

Data Dumps | MySQL
A data dump of all the Canadian provinces and abbreviations in MySQL format. » View Post

U.S. State Abbreviations in MySQL Table

Data Dumps | MySQL
A data dump of all the U.S. states (and Washington, D.C.) and their abbreviations in MySQL format. » View Post

Copy MySQL Table Rows in PHP

This little chunk of PHP grabs all the rows from the source table and inserts them into an (identical) destination table. It's useful for backups or an automated process that you don't want to always be logging into phpMyAdmin to do. » View Post

Test PHP Connection to IMAP Mailbox

Simply enter your server location, account name, and password into this code and it will connect to your email account via IMAP (or display the reason why it couldn't connect). » View Post

Simple PHP Image Upload Form

Images | PHP
This little chunk of PHP allows a user to upload a JPEG image and then resizes that image to generate a thumbnail automatically. With a little work, you can change the file types allowed, formula for resizing the thumbnails, etc. but I wanted to keep this simple so only JPEGs are allowed and everything is resized based on height. » View Post

Simple PHP Directory Script

PHP code that crawls through your local directory creating an array of files (of a specified extension). It then sorts those and prints them out as HTML links. » View Post
» First · Previous · Next · End · Categories