Category Archives: PHP

PHP is a programming language suited to a wide variety of tasks and widely supported by the web development community. Also in this category is PHP’s most common database buddy, MySQL

How to duplicate a phpBB3 theme

If you ever want to duplicate an existing phpBB3 theme, you might be sorely frustrated when you can’t seem to get any of your changes to take hold. It is sometimes necessary to go to the ACP, and hit purge the cache, however there is a further trick.

First, duplicate the theme folder you want to start with, and rename to your theme name.

Second, you need to go to the theme folder, and open style.cfg, /imageset/imageset.cfg, /template/template.cfg, /theme/theme.cfg, in a text editor. All of these files contain name = value. Rename all of these to your theme name.

Upload all of these changes, then head to the ACP and go to the “styles” tab. Click install on your theme.  On the left hand menu, go to each of the style components, and select install for each one. Then head back to the main styles page and click “details” for your theme. Select the imageset, template and theme from the dropdown menu.

Now you should be done!… Read more

Posted in PHP | 1 Comment

How to make a tag cloud in PHP, MySQL and CSS

Update May 2011: Almost 4 years on, this post continues to get heaps of traffic and comments so i’m going to attempt to answer some of the most FAQ. I have added the MySQL table structure and demonstrated how a basic search page would work to increment the search term counter. I’ve also added some pretty CSS3 and added a last search date for each term. If you just want the files to download, skip to the end.

Today I wanted to make a tag cloud, but all my searching proved fruitless – so I decided to stop being lazy and just work it out myself!

First you’ll need a database that stores the keywords and search terms.

Each time a user performs a search, we will check to see if the term has been searched before. If it has, we will increment the counter for that term. If the term has not been searched for before, we will insert the search term with a counter value of 1.

Lets begin with a basic MySQL table structure for the search table:

Now lets make a search page. Here is some basic HTML to get started with:

In the next section, we are going to accomplish three things:

  1. Connect to the database
  2. Handle new searches so that the counter can be updated
  3. query the database searches to build a PHP array of search terms

Next we’ll setup a bit of css. Feel free to adjust these as you see fit.

Finally we just want to loop through the array and display it with the appropriate css class.

And thats it! Hope this saves someone some time. Add your comments below!

I have combined this tutorial into a single file,  download the full example here.… Read more

Posted in PHP | 103 Comments

What is a Cron Job?

Q: What is a cron job?

A: A cron job is an automated task that runs on a linux server, similar to Scheduled Tasks on windows.

The main idea is that you can run a process without you or someone else manually setting it off – my first experience with cron jobs was when working with an online auction website. As you can imagine, an auction runs for a fixed time period. So lets say an auction runs for 7 days. What happens at the end of 7 days? The database says this auction is closed. If the auction did not sell, whether the reserve was not met, or their were no bids at all, then we want to automatically relist that auction.

There are two options:

a) run a process when a page load occurs… sucks because the page load is gunna take longer due to the extra processes occurring

b) run a cron job every x minutes, looking for auctions that have passed their end time, and either relist them or close them down permanently

I tend to code in PHP and MySQL, which means that I create a PHP file that does all the maintenance tasks required and I run it at set intervals. The cool thing is, if you want to be running different tasks at multiple times of the day/week/year, just setup multiple cron jobs.

Thats great, but how the hell do I setup a cron job?

I’m glad you asked!

If you are comfortable working with command line, then you might want to visit a site like this. If, like me, you have access to cPanel, life is much, much easier.

How to setup a cronjob in cPanel

1. login to cPanel

2. click on the cron jobs tab (near the bottom)

3. … Read more

Posted in PHP | 1 Comment