Web Development - Page 2 of 7 -

PHP Json data parsing

Json is a text-based format like xml . JSON is easy to read and easy to understand for humans and computers but Json occupy less bandwith compare to xml . JSON is the most popular and lightweight data-interchange format for website applications. Below is json object

JSON data structures are very similar to PHP arrays. Encoding and decoding of json data in php is very easy .PHP uses these two functions json_encode() and json_decode() for encoding and decoding of json data . Both functions only works with UTF-8 .

We have seen Json object , Now below is Json array inside Json object

How to encode Json data in php : – json_encode() function is uses to encode data to json format . The below example explanes how to use json_encode() in php for associative array .

Output of this code

{“Peter”:65,”Harry”:80,”John”:78,”Clark”:90}

How to decode Json data in php :-

Decoding json value is as simple as encoding .Now here we will use php json_decode() function convert the json encoded string to php data types

Output of code

9002020
23030030
78020292

See more tutorials on json & php

How to use chaining in Jquery

Jquery chaining allows us to run multiple methods togther .Simple chaining example :-

Now as you can see there is three methods css() , slideUp() & slideDown() and we can bind them together with help of Jquery chaining . You can also write this way . You can download Jquery from here www.jquery.com

Now i will show you complete example of chaining

Now run this code on your broswer Output :-

Lorem Ipsum is simply dummy text of the printing and typesetting industry Lorem Ipsum has been the industrys standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book It has survived not only five centuries

See more examples of Jquery  

How to use json data using php

Json is javascript object notation . It used for data exchange on server . Json is light weight data exchange format which is useful for server & website communication .

Take a real life example Suppose Website A in java and Website B is in PHP but if they want to communicate with each other or wants to exchange data with each other then they will use Json or xml .

Json is very easy to use & language independent .Json is used to storing and transport data on server . Json is text format so it can be transported anywhere

XML is difficult to parse than JSON.
JSON is parsed into a ready-to-use JavaScript object. JSON can use array for multiple data

Different Json data types

a string , a number , boolean , an array , an object (JSON object)

this is json object and we can convert it to javascript object using JSON.parse();  We write json data or object withing curly braces { } .Json data must be in key and value format , both key and value separated by single colon .

A common use of Javascript object notation is to exchange data to/from a web server.

When receiving data from a server, the data is always a string form.

we parse the data using JSON.parse()&then data becomes javascript object

Now using php code we can convert to json

Output of code

{“name”:”dheeraj”,”age”:”37″,”state”:”haryan”} This is output is in JSON format & we got this output by using json_encode(); function of php

Lets see another example of json ( How to use loop in json)

Output of code

Using loop in json

Employee Job
Email
Cell Number

Now how to access its property through loop

Output of code :

Using loop in json

comupting
[email protected]
211882

How array works in json

Output of code

Chemistry

data = jObj.subjects[2]; I gave index 2 so output is chemistry

How to use get & post methods in Jquery

I am going to use get method, usually we work on get and post method so Jquery has two methods for sending data from browser to server & receiving data from server $ .get() & $.post() . We can also use these methods for AJAX REQUEST . The basic syntax of post & get method :

$.get(URL , data , success) ; This for get method

$post(URL , data , success); This is for post method

The URL specifies where to send data , data is used for string data & success is a callback function that executed if the request succeeds .

Below is php code for multiplication table : – table.php

If you run this code in your browser

See more tutorials on Jquery and php

How to do form validation in javascript

The validation part of javascript is very easy

This below code block is doing validation

if(name == “”) {
printError(“nameError”, “Please enter your name”);
} else {
var regex = /^[a-zA-Z\s]+$/;
if(regex.test(name) === false) {
printError(“nameError”, “Please enter a valid name”);
} else {
printError(“nameError”, “”);
nameError = false;
}
}

If you run this code in your broswer

 

 

 

 

Candidate Info Form

 
 
 
 
 

 

See PHP and JQUERY Tutorials

 

http://www.goolik.com/pdo-registration-in-php/
http://www.goolik.com/move-object-using-javascript/
http://www.goolik.com/how-to-use-accordion-in-jquery/
http://www.goolik.com/add-remove-class-using-jquery-ui/

Move object using javascript

imgObj.style.left = ‘0px’; It is used to set object at left side with zero px .

imgObj.style.left = ‘100px’; If you set 100px; then it will leave 100px from left side

imgObj = document.getElementById(‘img’); imgObj is a variable and storing img id ( id = “img”)

function moveRight()
{
imgObj.style.left = parseInt(imgObj.style.left) + 100 + ‘px’;
} // I Called this function to onClick event of input button

If you run this code

JavaScript Move right left Animation

Click button below to move the image to right

How to use accordion in Jquery

Accordion is like a tab which hold paragraph or any contents . It is expandable and collapsible , it broken into many sections

If you run this code in your browser output :

Learn about jquery accordion functionality

What is PHP?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,

Why PHP is light weight

when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,

What is Jquery

Jquery is a javascript library . It is light in weight and free to use .It provides all types of features . Jquery is easier than javascript

What is angularjs

Angularjs is a javascript front-end frameworlk like vue.js and reactjs angularjs is free to use

Another way to use accordion

If you run this code output:

Learn about Jquery accordion

What is PHP?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,

Why PHP is light weight

when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,

What is Jquery

Jquery is a javascript library . It is light in weight and free to use .It provides all types of features . Jquery is easier than javascript

What is angularjs

Angularjs is a javascript front-end frameworlk like vue.js and reactjs angularjs is free to use

Off accordion On accordion

Add Remove class using Jquery UI

addclass() method used to change css properties .This is the syntex of addClass method :-
.addClass( className [, duration ] [, easing ] [, complete ] ) 

Explanation of syntex :-P

  • ClassName: It is a string which contains CSS classes.
  • Duration:This is used to for time duration. 1000 miliseconds it means you have set 1 second 2000 – > 2 Seconds ,10000 Miliseconds ->10 Seconds.

If you run this code then your output :-

Learn How to add & remove class using Jquery
JQuery is a javascript library

One more example of Add Remove class

If you run this code in your browser output:-

Add Remove Class in Jquery UI

Jquery is javascript library

See more examples of php and jquery

JQuery UI Toggle

The toggle() method toggles between hide() and show() for the selected elements

If you run this code your output :-

Check our more tutorials on PHP and JQuery

How to get area of traingle using PHP Code

Area of traingle is calculated by this formula : –
(base * height) / 2 = Area

If you run this code in your browser Output:-

Base of Traingle:

Height of Traingle :

How to get armstrong number using PHP Code

See more tutorials on php