.bind() Event In Jquery

.bind() is a event , which is useful to attach the function needs to execute with exist/new  hander.

SYNTAX:

.bind( eventType, [ eventData ], handler(eventObject) )

It is similar as .live().

Example.

$(‘#bindclik’).click(function(){ alert(“1”); });

$(‘#bindclik’).bind(‘click’,function(){alert(“2”); });

When we click on element with ID “bindclik” alert message “1” and “2” will trigger. Mostly we can use this when we need to create event dynamically for a element.

.live() Event In Jquery

.live() usefully when we need to trigger a action for bulk of elements which match the current selector, now and in the future.

SYNTAX:

.live( eventType, eventData, handler )

eventType :such as click,change ,keydown…

eventData : data that need to pass to the event handler.

handler: function to trigger.

Example:

$(‘.classname’).live(‘click’,function(){ alert(“alert for live event click”); });

Here the click handler will trigger for all class as “classname”. ie., when we click on an any element which is having the class=”classname”  the alert will display.

Jwizard In Jquery

Last week I am learn Jwizard plugin in Jquery.

Its is like creating tabs in horizontal or vertical.  Its is a easy to show the contents in tabs. And also by passing arguments while calling jwizard we control the activities of the jwizard(like close btn, color,…). It has many flexible features.

Here is the simple understandable of example.

I just alter a plugin to validate the fields used in it. I wrote validation function in another jquery file. And I called the function inside jwizard function if its at required placed.

Example: we may use the jwizard plugin in several place . But I need the validation in a particular place only. so I can check the exact ID is alive(by finding length), the call external validation function unless continue inside jwizard(Make sure while alter plugin, it must not affect any where when we call jwizard).

Today Session

today class:

Wow today class starts at amazing thing to me.
I say thanks to Chandarshaker sir to share this idea
The tool which used to make design(front look0 view for a website using the following things
Http://lumzy.com
this can be used to works on on-line design.
Http://pencil project
this can download the tool from this site and install as local application in your system.
Then the class continue on last php session.

Mysql>
>use DBname;
select database(); //shows the current using DB
DML->select,insert,delete,update.
phpmyadmin

PHP DB:

better to use mysqli_connect instead of mysql_connect
to connect DB
syntax : $db = mysqli_connect(host, user, password, database) or die(mysqli_connect_error(); //die returns connection error
mysqli_close($db);
$mysqlquery=”select * from tablename”; //we can use all mysql query here
mysqli_query($db,”mysqlquery”) or mysqli_error();  // die returns query error
TO STOP DISPLAY ERROR IN BROWSER:
<?
ini_set(“display_errors”, FALSE);
?>
INSERT DATAS:
$format=”INSERT INTO tablename(col1,col2,col3) VALUES(‘%s’,’%s’,’%s’)”; //the args must me
$query=spintf($format,$REQUEST[name],$REQUEST[name],$REQUEST[name]);
mysqli_query($db,”query”)
monitor log:
$tailf /opt/lampp/logs/acess_log //to monitor access status
$tailf /opt/lampp/logs/error_log //to monitor error status

Today Session PHP array.

Today session continue with PHP array functions in PHP.

$GLOBALS[‘a’]=10; or global $a;

Array Functions:

in_array(searchvalue , $arrayname) – to find whether a element is there in a array or not.

Eg:

$a = array(“hi”, “hello”, 1014);

in_array(“hello”, $a); //return boolean

array_key_search(searchkey , $arrayname) – to find whether the given key is present in the array.

Eg:

$users = array(“John”=>”john123, “Sam”=>”sam34″, “Jones”=>”jones444″);

print array_key_search(“John”, $users); // return boolean

array_search(searchvalue , $arrayname) – to find an element in the array.

Eg:

$users = array(“John”=>”john123, “Sam”=>”sam34″, “Jones”=>”jones444″);

print array_search(“jones444″, $users);

array_key_exists(searchkey , $arrayname) – to check whether a key exists in an array.

Eg:

array_key_exists(“Sam”, $users);

Stack:

array_push($arrayname , addvalue) – to insert the element at the end of the array.

Eg:

$a = array(10, 20, 30, 40);

array_push($a, 50);

array_pop($arrayname) – to delete the element from last in a array.

Eg:

$a = array(10, 20, 30, 40, 50, 60);

array_pop($a);

Queue:

array_unshift($arrayname , addvalue) – to add the element in the beginning of the array.

Eg:

$arr = array(10, 20, 30, 40);

array_unshift($arr, 50);

array_shift($arrayname) – to remove the elements from beginning of an array.

Eg:

$arr = array(10, 20, 30, 40);

array_shift($arr);

array_keys($arrayname) – to get only the keys of the elements in an array.

array_values($arrayname) – to get only the values in an array.

Eg:

$arr = array(“str”=>”hello”, “number”=>24):

$a1 = array_keys($arr);

$a2 = array_values($arr);

unset($arrayname[key]) to remove the variable.

Eg:

$names = array(“John”, “Sam”, “Jones”, “Bourne”);

unset($names[2]);

array_rand($arrayname)to get an element from an array randomly.

Eg:

$nums = array(10, 20, 30, 40, 50);

for($i=0; $i<5; $i++){

$key = array_rand($arr);

print $arr[$key];

unset($arr[$key]);

}

shuffle($arrayname)to shuffle the elements in an array. Here the indexes are not shuffled.

Eg:

shuffle($arr);

count($arrayname) to find the number of elements in an array.

E g :

count($arr);

count_array_values($arrayname)to find the number of occurrences of an element in an array.

Eg:

<?php $arr = array(10, “John”, 10, 10, 20, 30, 10, “Smith”, 10, “John”, 50, 50);

print_r(count_array_values($arr)); ?>

array_filter($arrayname , callback())to filter the array elements using a callback function.

array_map($arrayname , callback()) to iterate over the array elements and call a callback function for each element in an array.

Eg:

<?php

function div_by_11($x){

return $x % 11 == 0;

}

function is_prine($x){

for($i=2; $i<$x-1; $i++){

if($x % $i == 0){

return FALSE;

}

}

return TRUE;

}

$functions = array(“div_by_11″, “is_prime”);

function process_array($f){

$arr = array(10, 44, 55, 22, 31, 67, 88, 23, 9, 156, 323, 77, 33, 91, 64);

print_r(array_filter($arr, $f));

}

array_map(“process_array”, $functions);   ?>

array_unique($arrayname)to remove the duplicate elements from an array.

Eg:

<?php $arr = array(10, 20, 10, 30, 20, 30, 20);

print_r(array_unique($arr));  ?>

sort($arrayname)to sort the elements of an array in ascending order.

Eg:

sort($arr);

array_walk($arrayname , callback())calls the user defined function for each element in an array iteratively. This function will modify the existing array.

Eg:

<?php $names = array(“John”, “Jones”, “Sam”, “Smith”, “Bourne”);

function to_upper(&$x, $y){

$x = strtoupper($x);

}

array_walk($names, “to_upper”);

print_r($names); ?>