One of the first questions that comes up when someone starts using PHP and the very powerful MySQL database is: How do I page through the results of a query like I see with search results on many web sites? This is pretty easy to accomplish if you know how to use the MySQL LIMIT clause. The LIMIT clause allows you to select a numeric range of results from a recordset that … [Read more...]
MySQL One Liners
We have been using PHP and MySQL for web development almost exclusively for several years. During this time, our team has come up with a list of simple, yet powerful one line SQL statements that make MySQL easier to use. We thought we might share them with you. Check out the list and feel free to submit your favorite MySQL one liner statements in the Leave a Reply section … [Read more...]
Creating a States Table in MySQL
It is common to add a drop-down select box that is populated with USA states or Canadian provinces to PHP applications. There are basically three ways to do this. You can hard-code all of the Select box selections into your application, you can add the states to a MySQL database manually, or you can use the handy code on this page to create a States table in MySQL in just a few … [Read more...]
Using a MySQL Full-Text Search
A full-text search allows a search of multiple text columns. If you are setting up a search of a series of articles or a site with lots of product-related content, a MySQL FULLTEXT search can make it very easy to find articles or products related to the keywords used by a searcher. This search method does exactly what its name implies--it allows a full search of large text … [Read more...]
Using MySQL Data Types
Learning how to use the MySQL database properly can take quite a bit of time. It is not uncommon to select a less than optimal data type when setting up a new table. Multiple data types are available for each value that you wish to store. This MySQL data type tutorial is intended to help take some of the mystery out of the proper type selections for database columns. The … [Read more...]
Preventing SQL Injection with MySQL and PHP
Most new web developers have heard of SQL injection attacks, but not very many know that it is fairly easy to prevent an attacker from gaining access to your data by filtering out the vulnerabilities using MySQL extensions found in PHP. An SQL injection attack occurs when a hacker or cracker (a malicious hacker) attempts to dump the data in a database table in a … [Read more...]