Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

PHP and MySQL

PHP en MySQL in 't kort...
by

Ron Wessels

on 11 December 2017

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of PHP and MySQL

Variables
<?php

$my_string = "";
$my_int = 0;
$my_float = 0.00;
$my_array = array();
$my _object = new StdClass();

?>
echo
<?php

echo "Hello Philippines!";
echo $my_variable;

?>
PHP
<?php

// line of code here followed by semicolon (;)

/*
a comment
*/

// another comment

?>

INTERNET
AJAX
.php
PC
Javascript
Database
Google.com
SEO
CSS
HTTP
HTTPS
Website
Data Center
domain name
WWW
Browser
Flash
HTML
How PHP works?
Conditional Statements
if ... else
loops
for
foreach
while
do... while
switch
Operands
==
!=
>
<
>=
<=
Constants
<?php
define('MY_NAME', 'Emman');
?>

<html>
<body>
<?php echo MY_NAME; ?>
</body>
</html>
Arrays
<?php
$color = array( 'red', 'blue' );
$color[] = 'black';

echo $color[0]; // red
echo $color[1]; // blue
echo $color[2]; // black

?>
Arrays
<?php

$my_info = array(
'fname' => 'Emman',
'lname' => 'Sayson',
'occupation' => 'programmer'
);

echo $my_info['fname'];


$my_info['fname'] = 'John';
$my_info['lname'] = 'Doe';
$my_info['occupation'] = 'Janitor';

?>
Multi-dimentional Arrays
<?php

$table = array(
'East' => array('January' => 'AA', 'February' => 'EE', 'March' => 'HH'),
'North' => array('January' => 'BB', 'February' => 'AA', 'March' => 'GG'),
'West' => array('January' => 'DD', 'February' => 'CC', 'March' => 'AA'),
);

echo $table['North']['February'];
?>
Exercise on
Form Handling
<?php
echo $_GET['varname'];
echo $_POST['varname'];
echo $_REQUEST['varname'];

echo $_SESSION['varname'];
echo $_COOKIE['varname'];
?>
Passing Data Between Pages
$_GET
Information sent from a form with the GET method is visible to everyone (all variable names and values are displayed in the URL).
The limitation is about 2000 characters.
Can be used for non-sensitive data, urls with data that can be bookmarked.
DON'T use to forms that sends password and other sensitive data.
$_POST
Information sent from a form with the POST method is invisible to others (all names/values are embedded within the body of the HTTP request) and has no limits on the amount of information to send.
Moreover POST supports advanced functionality such as support for multi-part binary input while uploading files to server.
$_REQUEST
by default, it contains the contents of $_GET, $_POST and $_COOKIE.
expensive to use than $_POST and $_GET
$_SESSION
An associative array containing session variables available to the current script.
Need to be used with session_start();
$_COOKIE
An associative array of variables passed to the current script via HTTP Cookies.
Include & Require
The include or require statement takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement.

<?php

include 'my_section.php';
require 'another_section.php';

?>
Functions
<?php

echo "today is " . get_formatted_date();

function get_formatted_date() {
$today = date("F d, Y");
return $today;
}

?>
Exercise on
www.pelato.nl:
PHP Advanced Training
.sql
SQL is a standard language for accessing databases.

language use to manipulate data held in RDBMS
Structured Query Language
PHP + MySQL
mysql_connect
<?php

$user_name = "root";
$password = "";
$database = "mydb";
$server = "127.0.0.1";

$db_handle = mysql_connect($server, $user_name, $password);
echo "Connection to the Server opened";

?>
mysql_select_db
<?php
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {
echo "Database Found " . $db_handle;
}
else {
echo "Database NOT Found " . $db_handle;
}

?>
mysql_close
<?php
mysql_close($db_handle);
?>
Getting Table Data
<?php
$sql = "SELECT * FROM tb_my_table";
$result = mysql_query($sql);

while ( $db_field = mysql_fetch_assoc($result) ) {

echo $db_field['field1'] . $db_field['field2'];

}
?>
magic quotes - preventing SQL injection
mysql_real_escape_string( )
htmlspecialchars()
http://thephpbasics.com/basic-php-tutorials/
Full transcript