SQL Statement

SQL Statement Syntax
AND / OR SELECT column_name(s)
FROM table_name
WHERE condition
AND|OR condition
ALTER TABLE ALTER TABLE table_name
ADD column_name datatypeor
ALTER TABLE table_name
DROP COLUMN column_name
AS (alias) SELECT column_name AS column_alias
FROM table_nameor
SELECT column_name
FROM table_name  AS table_alias
BETWEEN SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
CREATE DATABASE CREATE DATABASE database_name
CREATE TABLE CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name2 data_type,
...
)
CREATE INDEX CREATE INDEX index_name
ON table_name (column_name)or
CREATE UNIQUE INDEX index_name
ON table_name (column_name)
CREATE VIEW CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
DELETE DELETE FROM table_name
WHERE some_column=some_valueor
DELETE FROM table_name
(Note: Deletes the entire table!!)
DELETE * FROM table_name
(Note: Deletes the entire table!!)
DROP DATABASE DROP DATABASE database_name
DROP INDEX DROP INDEX table_name.index_name (SQL Server)
DROP INDEX index_name ON table_name (MS Access)
DROP INDEX index_name (DB2/Oracle)
ALTER TABLE table_name
DROP INDEX index_name (MySQL)
DROP TABLE DROP TABLE table_name
EXISTS IF EXISTS (SELECT * FROM table_name WHERE id = ?)
BEGIN
--do what needs to be done if exists
END
ELSE
BEGIN
--do what needs to be done if not
END
GROUP BY SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
IN SELECT column_name(s)
FROM table_name
WHERE column_name
IN (value1,value2,..)
INSERT INTO INSERT INTO table_name
VALUES (value1, value2, value3,....)or
INSERT INTO table_name
(column1, column2, column3,...)
VALUES (value1, value2, value3,....)
INNER JOIN SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
LEFT JOIN SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
RIGHT JOIN SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
FULL JOIN SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
LIKE SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
ORDER BY SELECT column_name(s)
FROM table_name
ORDER BY column_name [ASC|DESC]
SELECT SELECT column_name(s)
FROM table_name
SELECT * SELECT *
FROM table_name
SELECT DISTINCT SELECT DISTINCT column_name(s)
FROM table_name
SELECT INTO SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_nameor
SELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name
SELECT TOP SELECT TOP number|percent column_name(s)
FROM table_name
TRUNCATE TABLE TRUNCATE TABLE table_name
UNION SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
UNION ALL SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2
UPDATE UPDATE table_name
SET column1=value, column2=value,...
WHERE some_column=some_value
WHERE SELECT column_name(s)
FROM table_name
WHERE column_name operator value

AngularJS Tutorial Part 1



AngularJS Tutorial

AngularJS extends HTML with new attributes
AngularJS is perfect for SPAs (Single Page Applications)
AngularJS is easy to learn

Try it Yourself Examples in Every Chapter


<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="">
  <p>Name: <input type="text" ng-model="name"></p>
  <p ng-bind="name"></p>
</div>

</body>
</html>


What You Should Already Know
Before you study AngularJS, you should have a basic understanding of:
  • HTML
  • CSS
  • JavaScript

AngularJS Introduction


AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag.
AngularJS extends HTML attributes with Directives, and binds data to HTML with Expressions.

AngularJS is a JavaScript Framework

AngularJS is a JavaScript framework. It is a library written in JavaScript.
AngularJS is distributed as a JavaScript file, and can be added to a web page with a script tag:
<scriptsrc="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>


AngularJS Extends HTML

AngularJS extends HTML with ng-directives.
The ng-app directive defines an AngularJS application.
The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.
The ng-bind directive binds application data to the HTML view.
Example explained:
AngularJS starts automatically when the web page has loaded.
The ng-app directive tells AngularJS that the <div> element is the "owner" of an AngularJS application.
The ng-model directive binds the value of the input field to the application variable name.
The ng-bind directive binds the innerHTMLof the <p> element to the application variable name.
Note
You can use data-ng-, instead of ng-, if you want to make your page HTML5 valid.


AngularJS Expressions
AngularJS expressions are written inside double braces: {{ expression }}.
AngularJS expressions bind data to HTML the same way as the ng-bind directive.
AngularJS will "output" data exactly where the expression is written.
AngularJS Example
<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="">
  <p>My first expression: {{ 5 + 5 }}</p>
</div>

</body>
</html>


AngularJS Directives


AngularJS lets you extend HTML with new attributes called Directives.

AngularJS Directives

AngularJS directives are extended HTML attributes with the prefix ng-.
The ng-app directive initializes an AngularJS application.
The ng-init directive initialize application data.
The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.
<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-init="firstName='John'">

<p>Input something in the input box:</p>
<p>Name: <input type="text" ng-model="firstName"></p>
<p>You wrote: {{ firstName }}</p>

</div>

</body>
</html>
Data Binding
The {{ firstName }}expression, in the example above, is an AngularJS data binding expression.
Data binding in AngularJS, synchronizes AngularJS expressions with AngularJS data.
{{ firstName }} is synchronized with ng-model="firstName".



AngularJS is perfect for database CRUD (Create Read Update Delete) applications.
Just imagine if these objects were records from a database.
Repeating HTML Elements
The ng-repeat directive repeats an HTML element:
<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-init="names=[
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]">

<p>Looping with objects:</p>
<ul>
  <li ng-repeat="x in names">
  {{ x.name + ', ' + x.country }}</li>
</ul>

</div>

</body>
</html>

Note
AngularJS is perfect for database CRUD (Create Read Update Delete) applications.
Just imagine if these objects were records from a database.

The ng-app Directive

The ng-app directive defines the root elementof an AngularJS application.
The ng-app directive will auto-bootstrap(automatically initialize) the application when a web page is loaded.
Later you will learn how ng-app can have a value (like ng-app="myModule"), to connect code modules.

The ng-init Directive

The ng-init directive defines initial valuesfor an AngularJS application.
Normally, you will not use ng-init. You will use a controller or module instead.
You will learn more about controllers and modules later.

The ng-model Directive

The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.
The ng-model directive can also:
  • Provide type validation for application data (number, email, required).
  • Provide status for application data (invalid, dirty, touched, error).
  • Provide CSS classes for HTML elements.
  • Bind HTML elements to HTML forms.

The ng-repeat Directive

The ng-repeat directive clones HTML elementsonce for each item in a collection (in an array).

AngularJS Controllers


AngularJS controllers control the data of AngularJS applications.
AngularJS controllers are regular JavaScript Objects.

AngularJS Controllers

AngularJS applications are controlled by controllers.
The ng-controller directive defines the application controller.
A controller is a JavaScript Object, created by a standard JavaScript object constructor.
<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-controller="personController">

First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}

</div>

<script>
function personController($scope) {
    $scope.firstName = "Kumar",
    $scope.lastName = "Suresh"
}
</script>

</body>
</html>
Application explained:
The AngularJS application is defined by ng-app. The application runs inside a <div>.
The ng-controller directive names the controller object.
The personController function is a standard JavaScript object constructor.
AngularJS will invoke personController with a $scope object.
In AngularJS, $scope is the application object (the owner of application variables and functions).
The personController creates two properties (variables) in the scope (firstName and lastName).
The ng-model directives bind the input fields to the controller properties (firstName and lastName).

Controller Methods
The example above demonstrated a controller object with two properties: lastName and firstName.
A controller can also have methods (functions as object properties):

AngularJS Filters


Filters can be added to expressions and directives using a pipe character.

AngularJS Filters

AngularJS filters can be used to transform data:
Filter
Description
currency
------Format a number to a currency format.
Filter                                                                  
------Select a subset of items from an array.
lowercase
------Format a string to lower case.
orderBy
------Orders an array by an expression.
uppercase
------Format a string to upper case.


Adding Filters to Expressions

A filter can be added to an expression with a pipe character (|) and a filter.
(For the next two examples we will use the person controller from the previous chapter)
The uppercase filter format strings to upper case:
<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-controller="personController">

<p>The name is {{ lastName | uppercase }}</p>

</div>

<script src="personController.js"></script>

</body>
</html>

<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-controller="personController">

<p>The name is {{ lastName | lowercase }}</p>

</div>

<script src="personController.js"></script>

</body>
</html>
<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-controller="costController">

Quantity: <input type="number" ng-model="quantity">
Price: <input type="number" ng-model="price">

<p>Total = {{ (quantity * price) | currency }}</p>

</div>

<script>
function costController($scope) {
    $scope.quantity = 1;
    $scope.price = 9.99;
}
</script>

</body>
</html>


<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-controller="namesController">

<p>Looping with objects:</p>
<ul>
  <li ng-repeat="x in names | orderBy:'country'">
    {{ x.name + ', ' + x.country }}
  </li>
</ul>

</div>

<script src="namesController.js"></script>

</body>
</html>


<!DOCTYPE html>
<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>

<body>

<div ng-app="" ng-controller="namesController">

<p>Filtering input:</p>

<p><input type="text" ng-model="test"></p>

<ul>
  <li ng-repeat="x in names | filter:test | orderBy:'country'">
    {{ (x.name | uppercase) + ', ' + x.country }}
  </li>
</ul>

</div>

<script src="namesController.js"></script>

</body>
</html>

PUSH NOTIFICATION FOR ANDROID ( PHP )

for push notification you have to use only this code.. not more programing is required...

// this is the google apis url.. not need to change..

 $url = 'https://android.googleapis.com/gcm/send';

//$fieds is an array and $registatoin_ids is a device id for which you have to create push notification

//if you create push notification for multiple device then use $registatoin_ids  as

// device id is a device token which is unique for every device/cellphone

//$registatoin_ids = array(deviceid 1, device id 2, device id 3,.....);

$message = array("You have receiving a push notification");

//$message is a text which you want to send.. in message

        $fields = array(
            'registration_ids' => $registatoin_ids,
            'data' => $message,
        );

//GOOGLE_API_KEY use here google server key which is made by android developer..

// we use GOOGLE BROWSER Key

        $headers = array(
            'Authorization: key=' . GOOGLE_API_KEY,
            'Content-Type: application/json'
        );
        // Open connection
        $ch = curl_init();

        // Set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        // Disabling SSL Certificate support temporarly
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

        // Execute post
        $result = curl_exec($ch);
        if ($result === FALSE) {
            die('Curl failed: ' . curl_error($ch));
        }

        // Close connection
        curl_close($ch);
        echo $result;
// if your code is fine then result give you the response and success 1 if you got error then result give you error  message.. or failure 1

Frameworks to Build Mobile Application with HTML, CSS & JavaScript

For many web developers, which may only be familiar with HTML, CSS, and JavaScript, developing a native mobile app could be unfamiliar territory. Technically speaking, mobile apps in Android, iOS, and Windows Phone are built using completely different programming languages; an Android app uses Java, an iOS app uses Objective-C, while a Windows Phone app uses .NET.
But now, anyone with a decent knowledge of HTML, CSS, and JavaScript can build a mobile application. One key advantage of using web technology to build your app is Portability. Using a packager/compiler, like PhoneGap, you will be able to port and install your app on many different platforms.
There are a number of frameworks that make this possible. They also have done half of the hard work to bridge the gap between web and mobile platforms. Here we have put together 10 of the best mobile frameworks that we could find. If you are ready to build the next billion-dollar app let’s check out the list.

1. jQuery Mobile

jQueryMobile is a robust mobile development framework to build cross-mobile-platform app. jQuery Mobile support a wide range of different platforms, from a regular desktop, smart phone, tablet, or an e-reader device like Nook or Kindle. Similar to its sibling, jQuery UI, jQuery Mobile comprises a number of UI that, in this case, is optimized for mobile and touch-enabled devices.

2. Cordova / PhoneGap

PhoneGap is essentially based on Cordova. Cordova/Phonegap provides a set JavaScript APIs that connect to the device’s native functions such as Camera, Compass, Contacts, and Geolocation. Cordova/Phonegap lets us build a mobile application without the native programming language; instead we can use a framework like jQuery Mobile. It will compile your app using the platform’s SDK and will be ready to install on the platform it supports including iOS, Android, Windows Phone, Blackberry and Web OS.

3. Sencha Touch

Sencha Touch is a mobile framework powered by HTML5 and CSS3, providing APIs, animations, and components that are compatible with the current mobile platforms and browsers. Sencha Touch supports both Cordova and PhoneGap; you can compile your app, and submit your app to the respective platform’s App Stores. In addition, Sencha Touch provides a set of themes for iOS, Android, Blackberry, Windows Phone, Tizen, and a variety of other platforms to help your app feel like a native app.

4. Ratchet

Ratchet was originally used by Twitter as an internal tool to create their mobile app prototype which is then released publicly as an open source project. Ratchet comes with a collection of User Interface and JavaScript plugins for building simple mobile apps, providing reusable HTML classes. In version 2.0, Ratchet is also shipped with its proprietary font icon set named Ratcheticon and two pre-made UI themes for iOS and Android.

5. Ionic

If you are concerned with your app performance, Ionic is the right framework for you. Ionic is an HTML5 mobile framework with focus on performance, by leveraging hardware acceleration, and it requires no third-party JS library. It works best together with Angular.js to build an interactive app. Similar to Ratchet, Ionic is shipped with a nicely crafted font icon set, Ionicons, and a bunch of reusable HTML classes to build the mobile UI.

6. Lungo

Lungo is a lightweight mobile framework based on HTML5 and CSS3. It has very nice default styles that you can use as a starting point to design your mobile app. Aside for the mobile UI components, Lungo brings a number of JavaScript API to control your app. Lungo supports the following platforms: iOS, Android, Blackberry and Firefox OS.

7. jQT

jQT is a Zepto plugin for mobile framework primarily designed for Webkit browsers. jQT is easily customizable and extensible. It comes with a theme that can be modified using Sass/Compass, cool 3D transition that is adjustable via CSS3, plus developers could also extend jQT with their own required functionalities.

8. Junior

Junior is also a Zepto plugin for building a mobile app similar to jQT. But Junior is dependent on several external libraries for some features to work, namely Backbone.js, Flickable.js for creating a swipe-able slider, and Ratchet for the UI scaffold.

9. Jo

Jo supports a wide variety of mobile platforms including Tizen and Chrome OS. Jo also comes with a starter, that is powered by CSS3, so it makes it easy for web developers at any level of experience to grasp and start styling their apps. In addition, you can use Jo along with PhoneGap or Cordova to pack your app for use on mobile platform.

10. Famo.us

A new kid on the mobile framework block, Famo.us promises to eliminate HTML5 performance issue on mobile devices with its lightweight JavaScript engine (only 64k). Famo.us, reportedly, will a also launch a cloud-based service to package your app to publish to the AppStore – it sounds like Phonegap and Sencha will get a new competitor soon. You can sign up as a beta tester in www.famo.us to get your hands on it.

Google Ads

PHP skill test for PHP developers

Que.1 Who is called the father of PHP.

a) Larry Wall 
b)  Rasmus Lerdorf
c)  James Gosling
d)  Guido Van Rossum 


Que.2  What is the difference between print() and echo()?
a)  print() can be used as part of an expression, while echo() cannot.
b) echo() can be used as part of an expression, while print() cannot.
C)  echo() can be used in the CLI version of PHP, while print() cannot.
D)  both A and B

Que. 3  What is input sanitization?
a) Secure user input 
b)  Converting input into a format that PHP supports 
c)  Removing or cleaning potentially malicious user input. 
d)  All of the above
 




Que.4 The output of following script will be..


$somerar=15;

function ad it () {

GLOBAL $somevar;

$somerar++ ;

echo "somerar is $somerar";

}

addit ();

a) somerar is 15
b) somerar is 16
c)  somerar is 1
d)  somerar is $ somerar
Que.5  what will be the ouput of below code ? Assume that today is 2009-5-19:2:45:32 pm
<?php

$today = date("F j, Y, g:i a");
?> 
a) may 19,09,2:45:32 PM
b) May 19, 2009, 2:45 pm
c) May 19,2009,14:45:32 pm
d) May 19,2009,14:45:32 PM

Que. 6 What is the name of function used to convert an array into a string?

a)  explode()
b)  glue()
c)  implode()
D)  None of the above

Que. 7 If property of class is declare using var then PHP5 will treat the property as?
a)  Protected 
b)  Private 
c)  Public
d)  Final

Que. 8  What will be  the output of following script?
  
<?php
$test="3.5seconds";
settype($test,"double");
settype($test,"integer");
settype($test,"string");
print($test);
?> 


a)  3.5
b)  3.5seconds
c) 3
d)  3seconds 

Que.9 What is the name of function used to convert an array into a string?
a)  explode() 
b)  glue()
c)  implode() 
d)  None of the above 

Que. 10  The output of following script will be..

<?php
$x=array(4,2,5,1,4,5,3,4);
$y=array_count_values($x);
echo count($y);
?> 

a) 8
b) 7
c) 5
d) 28

Featured post

A23 Rummy - Safe Secure Gaming Platform

A23 Rummy is a popular online rummy platform in India. It is owned and operated by Head Digital Works Private Limited. The platform offers...