Archive for January, 2006

Following on from the previous post on IF statements.

An if statement is only executed once – if condition do this else do that. You can have more than one 'else', for example if condition, do this, else if condition, do this, else, do that.

[source:php]if (condition) {
do this
} else if (condition) {
do this
} else {
do that
}[/source]

You can have as many else if statements (elseif without a space is also allowed) as you wish however after a while the code can get out of control. A much neater way is to use a switch Statement (known to me as a case statement due to earlier programming learning!).

[source:php]$a = 2;
switch ($a) {
case "1" :
print "a is 1";
break;
case "2" :
print "a is 2";
break;
case "3" :
print "a is 3";
break;
default :
print "I gave up typing!!";
break;
}[/source]

A break statement is required at the end of each block of code here, otherwise the PHP would execute every line. break just means at that point break out of the curly brackets group you are currently in. It can be used in an if statement as well.

So just to recap:

The Ternary operator is perfect for a quick and basic if statement where you would only execute one line of code per condition. This cuts down your code and can neatly sit in between your HTML code.

The IF statement is more suited to multiple lines of code per option and to a maximum of 3 separate conditions.

The Switch / Case statement is suited to a situation where there could be more than 3 separate conditions available to meet.

Which to use and when? The Ternary operator should only really be used for the one liners. Otherwise it's down to personal choice however in my opinion once you have more than 3 elseif conditions then it is a lot easier to write and read a switch statement, it requires less coding and probably (although I couldn't say for certain without tests) executes quicker – I'm sure someone will be along soon to verify this!

Quick check today shows my osCommerce Templates site is back showing in the Google index. Now what Google is up to is beyond me. This time last week I had been indexed. I was showing for maybe 48 hours max and then dropped again apart from the front page. No reason at all. The site is not a spam site at all, it's a proper shop selling templates along with some affiliate links to eBooks of the same subject. Google seems to have been doing this to a few people however, indexing and showing all of their pages then suddenly dropping them out the SERPs again for a few days.nnNow last week I also happened to read on a forum about the use of filenames and how they work SEO wise and also how they look. On one of my sites I've gone for income and advertising over look which I'm really not a big fan of. I would rather forfit some income or visitors if it means having a better looking site as I believe these will last in the long run. As I already have my main keywords in my url I figured I didn't need to repeat them on a couple of pages so I shorted a couple of filenames (oscommerce-templates.php and oscommerce-ebooks.php) to just use 'osc' instead. This way they're still easy to see in the file structure for myself for updating but they don't look as spammy and it won't make a major difference as far as SEO is concerned.nnThinking that Google had dropped me altogether and would pick up on the 301 permanent redirects that I'd put in place I presumed that it would drop the old pages and replace with the new ones. However it seems that despite Google not showing me in the rankings it's still listing the old sites in the SERPs again even though they've been changed. So what is happening? It seems like Google is indexing a site, showing all of the pages and then hiding them for a short period and then showing them again without updating itself first! For a script (let's face it, googlebot is just a script) it's not highly intelligent at times. Luckily the 301s are still in place and will stay in place for as long as needbe but I'm more interested in what Google is really up to.nnHowever, all that aside, I'm back in the limelight so hopefully a sale or two will happen in the near future and I can make my money back on the site :)

It's been a hectic week this week hence the lack of posts. I've just taken on another new client and so am trying to get them sorted out with their updates and hopefully a redesign of their FrontPage web site as soon as possible. Thankfully Dave can take care of the 21+ email updates I've had through as it's all just basic HTML stuff and no PHP involved. However at this rate I'll be needing another PHP developer to help me out with the basics as I'm unbelieveably snowed under with PHP work still. I've passed on all my CSS, design and basic site stuff over and I'm still not finding any time to breathe.

I have meetings in London on Thursday with a current client for two new sites of his and a new client with a redesign. For the latter I need to get a whole CMS backend up and running for him by Wednesday night so that we can walk in on Thursday (Business lunch apparently!) and just play with the colours, show him how to update his site and that will be almost finished then. This is one of the newer quotes that I started doubling prices on so I'm looking forward to when this one is all paid for! I'm then off to Cardiff the following week to meet about 2 new sites that the company I contract for what, plus the redesign and amalgamation of their existing sites into one. As well as the administration site I've been setting up to integrate with their internal database system so that it can be easily accessed at home for on call work. I'm not complaining with them as I know that both Dave and I can live off my wages with them every month easily, so anything on top is just an added bonus. My debts are really beginning to clear now especially as I'm not having to pay out for much such as a holiday and Christmas, however i will start to look at flights for a holiday in May as I want to go away for my birthday.

The Tribal Tattoos site has really taken off this week. MSN UK indexed it and put us at the top for "tribal tattoos" and the visitors have jumped by 100 a day. We're now averaging around 225-240 a day which is great but the adsense income is really naff for it. Plus no sales on Amazon either. So I've started looking around to see what else we can offer. I've got a couple of people to contact but if anyone else has any suggestions please leave a comment as I'm open to everything!

Ever heard someone say "oh our web site is in Google, we're in place 3 and 4". I'm sure you've seen it yourself, you do a search on a phrase and in the first 10 results place 1 and 2 are from the same site. This is easily noticeable as Google will indent the second link, and of course the domain addresses will be the same. However look at this from the point of view of a searcher. The results page is showing the first two results are from the same domain, so they click on the link and it's not what they're looking for (for example), so they click back and then they'll most likely bypass the second link and go to the third result. I know I would. So therefore out of say a 50 page web site, 2 pages have been optimised for the same keyphrase and therefore one page is being wasted on it.

When you have 50 pages in a web site, each page is an entrance into your web site. So if you manage to get 2 pages appear on the results per search phrase that will decrease the number of entrances to 25. If you only have 25 ways in then that will equate to less visitors than you could be getting. If you have 50 pages then you need to target each and every page to a different phrase. I realise that due to the nature of some sites this is not always possible. Most business sites will have around 10 typical content pages such as the front page, about us, services etc. So there are 10 entrances that can be optimised to be unique in their own way. Take your subject, business type or niche phrases and use the various tools around such as Wordtracker to determine the best 10 phrases to optimise your site for (Wordtracker Tutorial). If you find more than 10 optimal phrases then see which ones can go conveniently together. I try to limit myself to 2 phrases per page as it's easy to integrate these in to the title, headers and body text.

Once all of this optimising is complete, if you still appear twice for certain phrases take a look at one of the pages and see why and how you can rectify this problem. Of course checking these key phrases in the Search Engines is a little time consuming so create a free account with Digital Point and let it's own software check your rankings in Google for you.

Time for a rant, it's been a while ;)

The day started off today with a friend telling me his Google adsense account had been suspended for invalid clicks. I know for certain that he's innocent in this so we've done some research and found a few others that had their accounts reinstated so fingers crossed he can prove to them that he's done nothing wrong and get his account back. There's a few $$ in there, it's not something you want to lose for doing nothing wrong but making Google money. It's a very thin line I think, that's easy to cross. I reminded myself of the Program Policies just to ensure that I wasn't crossing that line. I've amended a couple of things today just to be on the safe side. I also checked over the Inside Adsense Blog as they are constantly talking about how people are earning thousands of dollars on their network. Bizarrely enough they do not have one single post about what to do in the event of an account suspension. Instead you have to go out searching for information on the web because Google don't seem to answer this question on their Adsense help site! (And suddenly I hear my account being switched off as we speak!). I did find a couple of stories on forums and also a very good site which seems quite resourceful regardless of if you've been banned or not at I Am Banned.com.

The postman then came today with a nice big box for Dave and I. We'd both ordered new keyboards off Amazon on Monday. He just wanted a basic USB one whereas I decided to sort myself out with a Wireless Ergonomic/Natural Keyboard, as I prefer them because they're more comfortable. I opted for the only one I could find the Microsoft Wireless Optical Desktop Pro set which includes a mouse. I already have the mouse but I couldn't buy the keyboard separately so I figured I'll find a use for the other mouse at some point (so far I've lent it to Dave so it's not gathering dust!). However after an hour of using it I suddenly looked down and realised it has a US layout (The @ above the 2, the £ sign missing etc.). Incase you're wondering I touch type so I don't actually look at the keys hence why I didn't realise at first. So I thought, okay it's using a UK locale so that's fine, where's everything then. I found all the keys except the backslash. Then I realised I kinda need this a lot of PHP programming! I have looked and pressed every combination of keys but I can't find it! Trouble is because it's a US keyboard there is 1 key missing because it's not usually needed ie. the hash/tilde key. On the US layout the tilde is in the top left and the hash replaced the £ sign. So I've emailed Amazon and asked them if they can replace it with a UK keyboard, alternatively where's the backslash except for in the character map! The keyboard is now sitting on the floor and I'm back to typing directly on the laptop :(

And to top the day off (yes it wasn't really a bad day but it felt worse than it sounds) I discovered my osCommerce Templates site has been dropped out of Google again, all bar the front page. From one point of view it's good because it meant I could quickly go in and change some filenames from underscores to hyphens (more on that later) and set up the redirects just incase, but it means my visitors have dropped down again to literally a few a day. I'm hoping it's only a temporary glitch and I know I'm not the only one who's had it happen to them and I've seen sites go back in afterwards so I guess I just have to be patient.

On the upside however the Tribal Tattoos site seems to have been indexed into MSN UK search and our visitors have doubled over the past week to 230+ per day which I'm very happy about. We have double the visitors from MSN compared to Google which is not the usual ratio so once Google wakes up I'm hoping the visitors will hit into the thousands! But that's just hoping ;)

Page 3 of 6«12345»...Last »