PHP/MySQL
Find and Replace - PHP String Functions March 24, 2006After working with PHP for some time, you are undoubtedly going to have work with string functions. If you've ever manipulated strings using Microsoft Excel, the process is pretty similar. Here I am going to look at how to isolate the domain name from an email address. This technique uses several PHP string functions to determine the overall length of the string, isolate everything before the "@" symbol, and then finally return everything after the @ symbol, which is the domain name. If you simply want to find out if a string of text contains a certain string, PHP makes it easy with the strpos function. The basic syntax will look something like this: $string...Read entire article |
March 22, 2006 Since developing my own blog/content management system/RSS feeds I have learned a lot about how to manage this site and make it more efficient. I've created a backend system which, in essence, creates static HTML pages from data dynamically generated from a MySQL database. All this is done using PHP. I'm proud of the work and the amount of traffic, lower Alexa Rating, and higher Google PageRank that make the rewards that much sweeter. One of the drawbacks to creating my own system however has been working with the RSS feeds. As part of the administrative interface to this site is a "create archive" script. This single PHP file is responsible for creating everything you see on the front-end. After I click the link to generate the archive, a process goes on behind the scenes tha...Read entire article |
PHP Date Function Quick Reference March 17, 2006In a previous post, I talked about comparing dates in PHP and some techniques you may be able to use. I thought I would follow up on that post with a general guide to storing, retrieving, and working with dates in PHP. I think the best way to store dates in a MySQL database when using PHP is not to store them as MySQL defined dates, but rather as varchars. The varchar will actually be a Unix Timestamp. The benefit is that a date in a Unix Timestamp is literally a count of of the number of seconds since the epoch - January 1 1970 00:00:00 GMT. If you need to compare dates, it makes it as easy as seeing which number is higher or lower. Suppose, for instanc...Read entire article |
February 12, 2006 PHP makes it easy to store and retrieve data to a MySQL database. Statistics analysis is a pretty common application for PHP and MySQL. This involves storing some kind of data, retrieving that data, performing some kind of mathematical operation, and then displaying the results. This is a common function for something like Microsoft Excel as well. Numbers are stored in a spreadsheet, and using Excel's built-in data analysis functions, it will automatically perform mathematical operations and present the data in the form of a graphical display. Excel even goes a step further and let's you select what kind of graphical display you would like the data presented in. So how can you use PHP to present numbers and stats in a graphical display? My solution is quite eas...Read entire article |
January 18, 2006 When I first started working with PHP to create dynamic website content, it was mostly for simple directory projects. This included a simple admin with the ability to add, edit, and delete pure text. I remember the very first commercial project I worked on involved a directory listing of businesses, organized by location. Each listing had a name, address, city, state, zip code, phone number, fax number, website (if it had one), and main contact. The directory was location-based, so a viewer could select a state, and then a city to view relevant listings. It started out simple enough, but over time started to grow more complex as more functionality was added (to make the site more compelling to the visitor of course). At one point we decided to add coupons to the site so that v...Read entire article |
Storing Array Data in a MySQL Database Using PHP December 28, 2005
PHP is a great programming language to accomplish many dynamic/database tasks. When coupled with MySQL, you can literally do just about anything. I started using PHP and MySQL a few years ago and have put together some pretty complex sites. While I have no formal training in PHP, I have been able to do anything I want using the programming language. I learned from reading
One of the trickier concepts to tackle is the idea of arrays. In short, arrays allow you store mu...Read entire article
|
Creating an RSS Feed Using PHP December 08, 2005In a previous article I wrote about the benefits of having an RSS news feed on your site to syndicate your content and increase your ranking on Google and the other search engines. This is great, but how can website developers create their own RSS feed? I will describe the techniques I've used to create an RSS feed for this website using a MySQL database and PHP. The procedure is very similar to creating static HTML pages from database content using PHP. In essence you are retrieving content from a database, writing code to a variable, and then writing that variable to a file using the PHP function FOPEN. I actually find creating an RSS fee...Read entire article |
Creating a Static HTML Archive from a MySQL Database Using PHP December 05, 2005In an earlier entry I described how this site was created. In essence, I've created my own content management system which uses a MySQL database to store all the data, and a PHP script that converts the data into static HTML. This ensures that all the data stored in the database will get picked up by the search engines. But, there is much more involved than that and I feel as though I owe more of an explanation. Benefits of creating static HTML pages from data stored in a database The number one benefit is that all your precious content stored in your database will have a better chance of getting picked up on Google and the other search engines and will give your pages a better chance of ranki...Read entire article |