Archive for July, 2008

Is a date in a given range using PHP

Monday, July 21st, 2008

To find if a date is in a given data range, the quikest way is to turn all dates to Epoch dates and then do a compare.

So to test if 31/12/2007 is in a date range of 10-10-2000 and 10-10-2008 do the following

$From=”31-12-2007″;
$To=”10-10-2008″;
$Checkdate=”01-01-2008″;

if (
( mktime(0,0,0, date(”m”,strtotime($From)),date(”d”,strtotime($From)),date(”Y”,strtotime($From)))
<=
mktime(0,0,0,date(”m”,strtotime($Checkdate)),date(”d”,strtotime($Checkdate)),date(”Y”,strtotime($Checkdate))) )

&&

(mktime(0,0,0,date(”m”,strtotime($To)),date(”d”,strtotime($To)),date(”Y”,strtotime($To)))
>=
mktime(0,0,0,date(”m”,strtotime($Checkdate)),date(”d”,strtotime($Checkdate)),date(”Y”,strtotime($Checkdate))) ) ) {

print “In Date Range”;

} else {

print “Not in Range”;
}

Hope this helps.

Mamma Mia the Movie

Wednesday, July 16th, 2008

What can I say, I thoroughly enjoyed the film in its own right as a funny film with actors that keep busting in to song, and to be fair I recognised most of the songs.

The only painful part was Pierce singing, probably because he reminded me of my brother-in-law who sings in pubs in southern Ireland.

Apart from that, it was a very easy film to watch. So it gets my vote especially if you want to earn some brownie points.

According to MSN this week it has made over £7.5million pounds in the first week at the box offices so it sounds like a few people have be to see it already.

Building a database for your website Part 1

Sunday, July 6th, 2008

So you want a database for your website, so where do you start?

When I started to write this, I thought just a few lines with all the big bullet points in would do but after hitting 4 pages in ms word , I decided to split it down so here is Part1

Database Design for the Internet 101 Part1

Firstly you need to decide what information you will need? Sounds obvious but you don’t want to go down the spaghetti programming methodology if you can help it as it will cause you problems later on. So the best place to start is a blank A4 piece of paper and create an ERD.

An ERD is a graphical representation of the Database, where you can see the Relationships between the data you want to store. Drawing it out has a lot of advantages as you can chop and change it about very easily at the start before you build the database.

In these diagrams you can use the infinity sign to indicate a 1 to many relationship and lines to link fields. So as you can see from the example diagram above for each Registration you can have multiple payments.

In the Payments table there is a field called RegistrationID which links to the RegistratioinID in the Registration table. And then in the Payments table there is a Payment type which links to the Payments type table.

So why layout the data like this? Its all about data integrity, take the above example, if every time a payment was made the user had to enter a card type there could be all sorts of variations and typos in the table for example “VISA”, “Visa”,” VISA”,”Visa “, “Bisa” so by adding a PaymentsType table, this gives them the ability to select from a know and verified list. Going through this process is database normalization, for a database to work well you want to get to what is called the third nominal form where no data is replicated.

There ends Part 1, Part to will cover more on data relationships and normalization.

Do I need to do SEO Search Engine Optimisation

Wednesday, July 2nd, 2008

It’s not a resounding “YES” as you might think.

If your business is on the brink of closing then there are better ways to get exposure and possible sales over the Internet other than SEO.

These include PPC and traditional marketing activities. Another reason is that you are planning to totally change your website in the very near future, in this case its better to make sure your new website is written correctly in the first place and that will give you a good base to work from.

Do I need an external company to do my SEO?

99.9% of the techniques can be found by trawling the Internet and by using some common sense.

SEO is not a quick “switch it on” solution. It takes ongoing time, effort and energy.

So it’s a standard business decision whether you can allocate the time to do it your self or where it’s more cost effective to get an external company to do it.

You see companies offering SEO from £100 one off fee; basically these need to be avoided like the plague as just doing a couple of hours work and then never revisiting the site will NOT work.

SEO will take time it’s not an over night fix and should be considered an ongoing project.

We are currently writing a series of documents on DIY Optimisation for those people that want to do it for them selves and these should be available in August 2008 so please pop back to read them.

How to make php code run in .html files

Wednesday, July 2nd, 2008

This is a fairly simple one. If your website is hosted on an Apache Web Server then you can just edit or add a file called .htaccess. Inside this file you will need to add a line

addType application/x-httpd-php .php .phtml .html

This tells the web server that files ending in .php .phtml and .html are to be checked for PHP code.

By using the .htaccess method you will not need to restart apache to pick up the changes as apache looks for the .htaccess file each time a page is requested.

If you have to create an .htaccess file you will need to make sure the file permissions on it are 644. Or if setting via an ftp package Owner = Read/Write and the Group and Other will be set to READ only.

You should now be able to put sections anywhere in your html pages.

So why would you want to do this? There are a number of reasons, some of which are

  • Standard Header and Footers
  • Standard Menus
  • Displaying Date & Time
  • Displaying information from a database