Displaying all posts with the tag 'example'
I recently noticed a spout of emails coming into my inbox that have background images!? As many developers know background images in outlook are non existant, unheard of, a miricle!
So as any self respecting developer would do i jumped straight onto google with the string of keywords "when did outlook start supporting background images". Well, as it turns out a backround *image* does work, its background *images* that do not.
I came accross a blog that then explains that background images do not work in Outlook (thank goodness im not going crazy!) - but what will work is one single background image that sits in the body tag! There is one little snag that you will need to deal with (as if a Microsoft product would just work!). While every other client seems to gracefully assume no-repeat for the second part of the repeat line, Outlook does not. Take a look at the css code below and boom, you'll have body background images working.
When developing applications its inevitable at some point you'll be checking to see if something exists and if it doesn't; creating it in the database.
The way you've most likely been doing this is running a select query to see if it exists, grabbing the ID if it does exist then executing an UPDATE or noting it doesn't exist then executing an INSERT. It's time consuming and adds more unnecessary code you feel you probably don't need.
We have an answer!
There is a way to run an update within MySQL and make a note as to how many records it has updated, you can check to see if this is zero then run the insert code if need be, simple eh? Check out my example below and start counting up those saved seconds for another tea and biscuit break!
$result = mysql_query("UPDATE table SET notes = '' WHERE date = '$date'");
if (mysql_affected_rows() == 0) {
$result = mysql_query("insert into table () values ();");
}
We're developing a lot of applications that require things to happen on the page without refreshing, we use the jQuery library to achieve a lot of the results we require but while all this stuff is happening on the page sometimes need animation or the action you're about to achieve to wait a second.
To achieve this you'd usually use the standard setTimeout function within Javascript.
It does the job perfectly, right down the very millisecond; however, if you're asking the timer to pass a variable to the function you're asking it to run after a certain amount of time you'll find it falls on its feet and passes nothing at all.
All you need is a 'closure', closures are arguably the great secret of Javascript: the way variable scope stacks get frozen at the point of closure (and hence variables persist within the closure) is quite subtle and catches most out, including me! See what im talking about in the examples below
diarymessages = setTimeout('messagereel(newid);',10000);
diarymessages = setTimeout(function(){messagereel(newid)},10000);
Many of our customers ask us about how to take payments from their website, they're usually aware of the well known methods such as PayPal and Google Checkout; but these come with high costs in fee's which affects the price of the product they're selling.
The other alternative is to use your bank, which usually provides an internet supplier who deals with their online payments directly. This comes at an even higher cost than the previous mentioned methods due to high setup costs, further ongoing monthly costs and a percentage plus fee for every transaction made. This isn't so bad if you're turning over tens of thousands each month, but for the average small trader who has only just started trading online this is a large drawback.
For over a year now we've been using a different method that requires absolutely no setup fee*, no monthly costs and only a small percentage fee for each transaction. (The * simply refers to the type of account you setup with them, their highest setup fee is £50, which is hardly a deal breaker). This company is called Nochex - and you can find their website at www.nochex.com
You get a dedicated account manager to lease with, their card processor is very customizable, you're able to accept all credit and debit cards and the percentage fee is variable depending on how many transactions you plan to process. If there we're any downsides to this service it's that each transaction will appear on your customer's statements as "Nochex" and this isn't changeable, you do need to keep a certain amount of money in your Nochex account so that you can refund any customers at any point, and this sometimes can be quite high depending on how much you plan to process.
It's important to note this is not a sales pitch, we're not getting anything for recommending this service, we simply wanted to point you in the right direction of a good company that offers a good service, and we’ve used them for over a year and recommended many customers to them.
If you want to get an idea of how much money they might** take from your online sale use the little tool we've created below. (** the transaction fee is variable, you will need to agree this with your account manager, the standard is 2.9% + 20p which is what our calculation is using below.)
Enter the cost of the item you're selling below and we'll tell you how much Nochex would take as a fee.
Here's a top tip to speed up anyone's day (so long as they spend their days typing code). Sometimes you may want to have an on/off status for a particular entry in a database. For example, in our CMS system you can make web pages visible or invisible to the public by simply clicking the on/off button for each page. To do this might involve looking in the database, finding a field, checking the value and changing it accordingly (eg 1 for on, 0 for off).
So without the need for all these lines of PHP and MySQL you can simply use the MySQL 'CASE' construct, which looks at a field, and changes it if it is a certain value, in much the same way as an if ... else statement (but with much less code!).
Have a look at the example below, this is a quick an easy way to say "If 'status' is set to 1, set it to 2, but if it is set to 2, set it to 1. And Bob's yer uncle!
mysql_query("UPDATE tablename SET status =
CASE status
WHEN 1 THEN 2 WHEN 2 THEN 1
END
WHERE id='14'");
If you've got a tip, correction or comment regarding our coding tips, get in touch from the contact page!
In some projects you sometimes need to print out the alphabet either for a search facility or maybe because you like letters, either way we found a solution today which we thought was worthy of sharing!
In PHP, there are more than 700 built-in functions. The one function im going to be sharing with you today is called "range". The range() function creates an array containing a range of elements that can be returned from low to high.
This function is mostly used with numbers like this: $number = range(0,3); but it can also be used with letters $letters = range('a','e'); Take a look at our examples and outputs below.
$number = range(0,3); print_r($number);
Array
(
[0] => 0
[1] => 1
[2] => 2
[3] => 3
)
$letters = range('a','d'); print_r($letters);
Array
(
[0] => a
[1] => b
[2] => c
[3] => d
)
If you've got a tip, correction or comment regarding our coding tips, get in touch from the contact page!
Hello, This is just to remind our customers that the standard rate of VAT will go up from 17.5 per cent to 20 per cent on 4 January 2011.
Its actually nothing to be worried about, you're being encouraged to spend spend spend before the rise but in actual fact if you were to spend £100 now compared with after the 4th January, it would only cost an extra £2.13 - hardly worth splashing out now to 'save' the difference.
Being a software development company we though it might be useful if we made you a little tool to see how much something might cost you after the VAT change compared with now (and by now i mean as i write this blog).
How much will things cost after VAT rises to 20%?