Random Banner Script using PHP

Written on 08/27 • 0 Comments

I wanted to start alternating the banner advertisements on this site so started looking around for the simplest way to randomly display a different banner in my case a few lines of code that included the link, image and some text. I found a number of scripts that all seemed a bit clunky. I started thinking there must be a better simpler way.

All the solutions I found used the php function rand. We end up having to generate a random number from a range e.g. rand (0,100); will give us a random number between 1 and 100. There are a few problems here, firstly the range needs to be set to reflect the number of banners we have in our array so therefore we end up having to count the items in the array or use a fixed number.

The problem with rand is it deals with integers not blocks of code. I started looking for an alternative and stumbled upon shuffle. Shuffle as you would expect takes our array and reorders it at random as you do with a deck of cards. If you shuffle a deck of cards hen take the top card you end up with a random card from the pack each time. The other good thing about shuffle is it shuffles the whole array without us having to specify the number of entries.

Continue Reading

Fixing a Broken Contact Form on a Joomla Site

Written on 06/18 • 1 Comments

If you are having the same problem as I have had with the Joomla contact form not delivering the mail to your email address maybe this solution can help. This problem only occurs under certain circumstances. You Joomla site is hosted on one webserver, your mail is on another and your DNS records on another. This circumstance is more common than you would expect, say you register your domain with 123-reg and enter your MX records here, your site is hosted elsewhere and you are using Google Apps (gmail for domains) for your email.

Continue Reading

Simple PHP alternative to a full CMS

Written on 03/20 • 0 Comments

Sometimes a when you build a website using a full content management system is not always an option. You may not want or be able to use a database or the clients budget might not stretch that far. This was the case in a recent project I undertook but I still wanted to use a single template.

Continue Reading

More articles can be found in the archives, feel free to have a look around and leave your comments.

Try a sample pack of 10 Business Cards for free from MOO

Upload images for the first side of your card. Choose up to 10 different images or designs. We accept high resolution JPEG, PNG, GIF or PDF files. Free standard shipping is included.