Archives for Playing with Data

Convert number to binary in Javascript

Why did it take me so long to find this? Probably because I didn’t use radix in my Google search. Of course. Thanks to “Philip M” for the clue and thanks to W3Schools.com for the reference (see here for more on the unary “+” operator to convert a string to number). var str = ’37′; [...]

Dates in PHP and MYSQL

You would think that with PHP and MYSQL having such a lovely relationship that using dates PHP in MYSQL (and vice versa) would be a little more intuitive.  I guess it is intuitive to those who speak UNIX. So say you want to select a recordset between two dates.  Here’s how: //start with a date [...]

Populate Array with Database record

Once you connect to your database (Access), you can iterate through the fields (not records!) and assign their value to an array, naming the key after the original field name. This creates an effective name/value pair that is accessible even after the database connection has been closed. Javascript example: var data = new Array(); for [...]

Line breaks in textarea from Access

To retain linebreaks in textarea from an MS Access database,  replace linefeeds with carriage return/linefeed pair and then save the input. Javascript example: strInput.replace(/\n/g, ‘%0D%0A’) This replaces all linefeeds (line breaks) in the strInput (using “/\n/g”) with %0D%A which signal end of data (same as a carriage return and linefeed). The original input from the [...]