To get a random row from a Microsoft SQL database you need to use the NEWID() function. This will generate a new random number for each row and order them by that new number. This is used in conjunction with the TOP clause to limit the amount of returned rows to one.
Those of you who have coded in PHP must have looked at the PHP website at some point, even if it was just to down load the latest version, or to look up a function reference.
What most people don't realise is that there is a really easy way to go straight to the page that you want without having to mess around with the tetchy search engine on the PHP site.
The following mode function will return the most commonly occurring value from an array of values, also called the mode. If just the array is used then only the most commonly occurring value will be returned. The second parameter can be used to return an array containing the mode and the number of times that this value occurs in the array.
I have previously talked about rounding numbers in PHP, but what if you wanted to round the number to the nearest thousand?
Reading or writing a file using PHP is quite a common practice, but it can often fall cause programs to fall flat on their face if the proper user privileges are not in place. Although this is not a problem on Windows machines due to the lack of a proper security model, but on Linux machines you need to make sure your scripts can run with the correct permissions.
Creating a new Draggable object with the script.aculo.us framework is easy. You just create a new instance of the Draggable object with the element id to be made draggable as the first parameter and a set of options as the second.
Here is a function to create a group of radio buttons in a HTML form. The three parameters are:
MySQL uses the datatype TINYINT to store boolean values. MySQL stores the value as TINYINT(1) which is the same as a bit so the value is either 0 (false) or 1 (true). Using boolean fields can be very useful, but it can be costly in processing as to change the value you have to query the database, find out the value of the field and then act accordingly.
Here is a simple MySQL query that can be used to toggle the value already present in the TINYINT field without having to do any pre-querying.