November 30, 2009
Convert decimal places without rounding
Category: PHP, khadlock at 1:13 pm
Here's a quick way to set the number of decimal places to 2 in PHP without rounding a number.
floor($decimal*100)/100
November 19, 2009
Remove all select options with JavaScript
Category: JavaScript, Tags: JavaScript, khadlock at 1:23 pm
Here's a quick function to remove all select options using JavaScript.
function RemoveAllOptions(selector) { while(selector.hasChildNodes()) selector.removeChild(selector.childNodes[0]); }
November 17, 2009
MySQL REGEXP: where first letter is numeric
Category: mysql, Tags: mysql, regexp, khadlock at 11:58 am
Get MySQL results where the first letter is numeric:
SELECT * FROM table WHERE (LEFT(columnname,1) REGEXP '[0-9]')
Or get MySQL results where the first letter is alpha:
SELECT * FROM table WHERE (LEFT(columnname,1) REGEXP '[a-z]')
November 15, 2009
Using the IN statement to retrieve multiple results from a subquery
Category: mysql, Tags: mysql, khadlock at 8:20 pm
Use the IN statement to retrieve multiple results from a subquery.
SELECT * FROM table WHERE id IN ( SELECT DISTINCT id FROM table WHERE id=1 )
November 14, 2009
Get MySQL results by first letter
Category: mysql, Tags: mysql, khadlock at 7:20 pm
The following SQL selects all the rows where columnname starts with the letter A, switch the letter or make it a variable and get the results you need.
SELECT * FROM table WHERE columnname LIKE 'A%'
Older Posts »
