Php Training Workshop by Vtips

24
PHP Made by:- Nupoor Garg M-tech(CSE) Professional Training In stitute

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 of Php Training Workshop by Vtips

Page 1: Php Training Workshop by Vtips

PHPMade by:-

Nupoor Garg

M-tech(CSE)

Professional Training Institute

Page 2: Php Training Workshop by Vtips

BRIEF HISTORY

PHP development

began in 1994.

Rasmus Lerdorf

CGI Perl scripts used to

maintain his personal

home page.

Page 3: Php Training Workshop by Vtips

PHP FULL FORMS

PERSONAL HOME PAGE PHP: HYPERTEXT

PREPROCESSOR

Page 4: Php Training Workshop by Vtips

DEFINITION

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

dynamic content in your website.

Page 5: Php Training Workshop by Vtips

WAMP SERVER

It automatically installs apache server.

Configures a MySQL database

Installs PHP support applications for easy mantainence and configuration.

Page 6: Php Training Workshop by Vtips

"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.

Page 7: Php Training Workshop by Vtips

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;

Page 8: Php Training Workshop by Vtips

OPERATORS

Arithmetic Operators

Logical (or Relational) Operators

Assignment Operators

Conditional (or ternary) Operators

Page 9: Php Training Workshop by Vtips

DATE FUNCTION IN PHP

• date(format)

• Print date with time

EXAMPLE:-

DATE( );

EXAMPLE:-

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

Page 10: Php Training Workshop by Vtips

Time zones

• To set the time zone

• To get the time zone

date_default_timezone_set();

date_default_timezone_get();

Page 11: Php Training Workshop by Vtips

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.

Page 12: Php Training Workshop by Vtips

Example (Numeric arrays)

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

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

Page 13: Php Training Workshop by Vtips

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>

Page 14: Php Training Workshop by Vtips

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.

Page 15: Php Training Workshop by Vtips

DATABASE CONNECTION

Page 16: Php Training Workshop by Vtips

STEP 1 :- TO ESTABLISH CONNECTION

<? PHP

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

IF($LINK)

{

ECHO “CONNECTION ESTABLISHED”

}

mysql_connect(host,username,password,databasename);

Page 17: Php Training Workshop by Vtips

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;

Page 18: Php Training Workshop by Vtips

• TO INSERT VALUES IN TABLE

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

Page 19: Php Training Workshop by Vtips

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.

Page 20: Php Training Workshop by Vtips

CONT..

• MYSQLI_QUERY($CON,”QUERY”);

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

connection

Page 21: Php Training Workshop by Vtips

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";}

?>

Page 22: Php Training Workshop by Vtips

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();

Page 23: Php Training Workshop by Vtips

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.