Subscribe For Free Updates!

We'll not spam mate! We promise.

May 26, 2013

Rounding Numbers to ‘N’ Decimal

Rounding Numbers to ‘N’ Decimal  This will let you round off a number to ‘N’ decimal places. In the below example we are rounding of a number to 2 decimal places. var num = 4.56789; alert(num.toFixed(2)); It will alert as 4.56. Another function to display a number upto a length is toPrecision(x). num = 520.2375; result = num.toPrecision(4); alert(result); It...

Generate Random number from 1 to N

Generate Random number from 1 to N Below little script helps you in generating random number between 1 to N. var random = Math.floor(Math.random() * N + 1); ...

May 23, 2013

Basic MySQL Query Commands

Basic MySQL Query Commands : Syntax for Query Commands 1. CREATE Command The Create command is used to create a table by specifying the tablename, fieldnames and constraints as shown below: Syntax: $createSQL=("CREATE TABLE tblName"); Example: $createSQL=("CREATE TABLE tblstudent(fldstudid int(10) NOTNULL AUTO_INCREMENT PRIMARY KEY,fldstudName...

May 21, 2013

Get body message content from mail using PHP

Get body message content from mail using PHP :  Here i will explain how to get mail contents(body of mail) by using php. Here i used two functions like imap_num_msg() and imap_body() which return the contents of a specific message respectively and the number of messages in the mail box. Syntax of these function: int imap_num_msg ( resource...

May 19, 2013

.htaccess Automatically redirect to Mobile Website

.htaccess Automatically redirect to Mobile WebSite :  Here i will explain how to redirect your website automatically to mobile scree website. This method is functioned from your website .htaccess. so this method is more efficient compare with find screen resolution and then redirect. The .htaccess only assign our websites url functionality in on-load of...

Use JSON in PHP 4 or PHP 5.1.x

Use JSON in PHP 4 or PHP 5.1.x :  Here i will explain how to use JSON (json_encode() , json_decode()) in versions of PHP earlier than 5.2. Add the following custom function to use (json_encode() , json_decode()) this functions in php. IF u don't have this JSON PEAR Package You can download in HERE 1. for json_encode() : if (!function_exists('json_encode'))...

May 10, 2013

php to remove last two characters from string

php remove last two characters from string  The following code is used to remove character from the last of the string. here "substr()" function is used. this function is used to get substring from original string. <?php echo substr('abcdef', 1);     // bcdef echo substr('abcdef', 1, 3);  // bcd echo substr('abcdef',...

May 9, 2013

Check String Contain Specific words - PHP

Check String Contain Specific words - PHP The following code is used to find the specific words or char from a string by using php. here "strpos()" is used. This function is used to get string position from the original string. here i just get true or false result if the original string contains the specific word or character, if (strpos($a,'are')...

May 7, 2013

Get URL from address bar - PHP

Get URL from address bar - PHP  The following code is used to get full url address by using php. <?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?> Notes:  Here we are using 2 functions in php to get full url from address bar. 1. $_SERVER['HTTP_HOST'] 2. $_SERVER['REQUEST_URI'] $_SERVER['HTTP_HOST']...

May 6, 2013

Random Password Generator

Random Password Generator  This tool is used to generate the random password that is generate random string with given "n" length. This tool is very use full for generate password with full secured. function f() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var n=document.getElementById("n").value; ...

May 5, 2013

Get details about an image in PHP

Get details about of an image in PHP: The following code is used to get the all details about image by using php and the result will be store in an array. <?php $filename = image.jpg; //image file path $imgDetails = getimagesize($filename); print_r($imgDetails); ?> The beloow code is simple to get width and height, type of the image...

May 4, 2013

Get cursor position in a textarea - Jquery

Get cursor position in a textarea - Jquery: The following code is used to get the cursor point in textarea. if you change the id of textarea with particular div id then you can get the cursor points within the div. (function ($, undefined) {     $.fn.getCursorPosition = function() {         var el = $(this).get(0);  ...

May 3, 2013

JQuery to get Current Date

JQuery to get Current Date:  The following code is used to get current date and time by using jquery.  Before that, Date() function is not the part of JQuery. it is one of JavaScript's features. var date = new Date(); var month = date.getMonth()+1; var day = date.getDate(); var output = date.getFullYear() + '-' + (month<10...

May 2, 2013

Random String Generator in PHP

Random String Generator in PHP:  The following function "getrandum_str()" is used to get the random string with specified string length. This function may used to get encrypted key value or generate the random password and etc... <?php function getrandum_str() {   $abc = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";  ...

JQuery to Find window Height

JQuery to set div in center of screen:  The following code is used to find the center position of the any size of the screen. here i set the div in center of the screen using jquery.   "$(window).height()" this function is used to get hight of the window(Screen). var divCenter= $('#div_id'); divCenter.css("top", ($(window).height()...

May 1, 2013

Find Browser and Platform Details Using JavaScript

Find Browser and Platform Details Using JavaScript: The following code is used to find the Browser and Platform details. This script displays browser code name, browser name, browser version, cookies enabled disabled details, platform details and user agent header details. <script> "Browser CodeName: " + navigator.appCodeName + ""; "Browser...