php training workshop by vtips

Post on 24-May-2015

436 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

The PHP training course offered by us is simply the best. The study materials and course modules are designed in a less complicated manner which can easily be understood by the students.

TRANSCRIPT

PHPMade by:-

Nupoor Garg

M-tech(CSE)

Professional Training Institute

BRIEF HISTORY

PHP development

began in 1994.

Rasmus Lerdorf

CGI Perl scripts used to

maintain his personal

home page.

PHP FULL FORMS

PERSONAL HOME PAGE PHP: HYPERTEXT

PREPROCESSOR

DEFINITION

PHP is a server side scripting language that is embedded in HTML. It is used to manage

dynamic content in your website.

WAMP SERVER

It automatically installs apache server.

Configures a MySQL database

Installs PHP support applications for easy mantainence and configuration.

"Hello World" Script in PHP

<HTML>

<HEAD> <TITLE> First program <TITLE> </HEAD>

<BODY> HELLO WORLD! </BODY

</HTML>

<BODY> <?php echo "Hello, World!"; ?>

PHP is embedded in

HTML.

VARIABLES IN PHP

All variables are declared with leading

dollar($) sign.

$sum=34; $sum=“hiii”;

PHP does a good job of automatically converting

types from one to another when

necessary.

Variable can, but do not need to be declared before assignment.

$vary=34; $many=5.34;

OPERATORS

Arithmetic Operators

Logical (or Relational) Operators

Assignment Operators

Conditional (or ternary) Operators

DATE FUNCTION IN PHP

• date(format)

• Print date with time

EXAMPLE:-

DATE( );

EXAMPLE:-

DATE( “d-m-y h:m:s” );

Time zones

• To set the time zone

• To get the time zone

date_default_timezone_set();

date_default_timezone_get();

ARRAYS IN PHP

• Numeric array

• Associative array

An array with a numeric index. Values are stored and accessed in linear fashion

An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.

Example (Numeric arrays)

• <?php$cars=array("Volvo","BMW","Toyota");

• Echo “I like”.$cars[2];• ?>

Example (associative array)

• <html> • <body> • <?php • $salaries['mohammad'] = "high"; • $salaries['qadir'] = "medium"; • $salaries['zara'] = "low";• echo "Salary of qadir is ". $salaries['qadir']."<br/>"; • ?> • </body>• </html>

HEADER,INCLUDE ANDREQUIRE

• HEADER

• INCLUDE

• REQUIRE

IT IS USED TO REDIRECT TO ANOTHER PAGE.

IT IS USED TO INCLUDE THE ANOTHER PAGE INTO THE CURRENT PAGE.

SAME AS INCLUDE.

DATABASE CONNECTION

STEP 1 :- TO ESTABLISH CONNECTION

<? PHP

$LINK=MYSQL_CONNECT(“LOCALHOST”,”ROOT”,””,”myd”);

IF($LINK)

{

ECHO “CONNECTION ESTABLISHED”

}

mysql_connect(host,username,password,databasename);

MYSQL BASIC QUERIES

• TO CREATE DATABASE

• TO CREATE TABLE

• TO LIST THE DATA

CREATE DATABASE DB_NAME;

CREATE TABLE TB_NAME(COL_NM1 DATATYPE,COL_NM2 DATATYPE……);

SELECT * FROM TABLE_NAME;

• TO INSERT VALUES IN TABLE

INSERT INTO TABLE_NAME VALUES(VALUE1,VALUE2……..VALUEN);

QUERIES TO BE USED WITH MYSQL

• MYSQLI_CONNECT();

• The mysqli_connect() function opens a MySQL connection.

• This function returns the connection on success, or FALSE on failure.

CONT..

• MYSQLI_QUERY($CON,”QUERY”);

• MYSQLI_CLOSE($CON);• Closes a previously opened database

connection

FETCHING DATA FROM MYSQL DATABASE

<?php$link=mysqli_connect("localhost","root","","mys");

if($link){

$tab=mysqli_query($link,"select * from m");while($row=mysqli_fetch_row($tab))

{echo "<br>"."value is:",$row[0];}

mysqli_close($link);}

Else{

echo "error";}

?>

ORDER BY RAND() FUNCTION IN MYSQL

• MySQL has a ORDER BY RAND() function that can be used to randomize the set of values.

• SYNTAX• SELECT * FROM TABLE_NAME ORDER

BY RAND();

WORDPRESS

WordPress is a free and open source blogging tool and a content-management system based on PHP and MySQL.

WordPress is an OPEN SOURCE project, which means there are hundreds of people all over the world working on it.

WordPress started as just a blogging system, but has evolved to be used as full content management system and so much more through the thousands of plugins and widgets and themes. WordPress is limited only by your imagination.

top related