This document discusses various PHP functions and concepts related to working with databases in PHP, including:
- PHP functions for arrays, calendars, file systems, MySQL, and math
- Using phpMyAdmin to manage MySQL databases
- The GET and POST methods for passing form data
- SQL commands for creating, altering, and manipulating database tables
- Connecting to a MySQL database from PHP using mysql_connect()
It provides code examples for using many of these PHP functions and SQL commands to interact with databases. The document is an overview of key topics for learning PHP database programming.
This ppt gives information about:
1. OOPs Theory
2. Defining a Class
3. Creating an Object
4. The $this Attribute
5. Creating Constructors
6. Creating Destructors
Loops execute a block of code a specified number of times, or while a specified condition is true.
Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use loops to perform a task like this.
In PHP, we have the following looping statements:
while - loops through a block of code while a specified condition is true
do...while - loops through a block of code once, and then repeats the loop as long as a specified condition is true
for - loops through a block of code a specified number of times
foreach - loops through a block of code for each element in an array
This ppt gives information about:
1. OOPs Theory
2. Defining a Class
3. Creating an Object
4. The $this Attribute
5. Creating Constructors
6. Creating Destructors
Loops execute a block of code a specified number of times, or while a specified condition is true.
Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use loops to perform a task like this.
In PHP, we have the following looping statements:
while - loops through a block of code while a specified condition is true
do...while - loops through a block of code once, and then repeats the loop as long as a specified condition is true
for - loops through a block of code a specified number of times
foreach - loops through a block of code for each element in an array
PHP stands for “PHP: Hypertext Preprocessor”. It is very good for creating dynamic content. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
This presentation gives introduction to ADO.Net.
Basic introduction to connected & Disconnected architecture.
and explain the each every component in Ado.net
1. Coding conventions
Object Naming Conventions
Variable naming conventions
Variable data types
Variable scope prefixes
2. Class Coding Standard
3. Define function or class when coding
4. Define database and table of database
PHP stands for “PHP: Hypertext Preprocessor”. It is very good for creating dynamic content. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
This presentation gives introduction to ADO.Net.
Basic introduction to connected & Disconnected architecture.
and explain the each every component in Ado.net
1. Coding conventions
Object Naming Conventions
Variable naming conventions
Variable data types
Variable scope prefixes
2. Class Coding Standard
3. Define function or class when coding
4. Define database and table of database
• PHP stands for PHP: Hypertext Preprocessor
• PHP is a server-side scripting language like ASP
• PHP scripts are executed on the server
• PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
• PHP is an open source software
• PHP is free to download and use
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
Lesson teached at Università di Roma Tre - Software Engineering course.
Web is plenty of amazing tools used daily by millions of people. A good idea can turn to be a highly profitable business if well executed. Yii framework is an ideal tool to build in short time an MVP of your product to start as soon as possible to find your market fit. Here follows some infos about the framework and steps on how to build a simple blog over Yii.
Ajax Performance Tuning and Best PracticesDoris Chen
Ajax Performance Tuning and Best Practices
Perhaps the most primary motivation to develop Ajax application is to have better user experience hence how to achieve the optimized response time becomes an important aspect in Ajax performance optimization. In this session, we will focus on discussing the improvement of the network transfer time and the JavaScript processing time as the server response is already generally well understood. We will use an Ajax framework case study to show how an Ajax optimization process can be used to optimize the performance. During the optimization process, we will demonstrate how to measure the performance, how to determine the bottlenecks and how to resolve the problems by applying various best practice. Various tools like NetBeans, Firebug, and YSlow will be illustrated to show when to use what and how to use them. The list of Ajax Performance tuning tips on combining CSS and JavaScript resources, setting the correct headers, using minifed JavaScript, GZip contents, and Strategically placing of CSS links and JavaScript tags will be discussed in the session.
Intermediate level Ajax and Enterprise developers can really benefit from this session.
After the session, the audience will be able to:
-apply Ajax Performance Optimization process
-choose the right tool and use them
-lleverage various best practice and performance tuning tips
-improve their Ajax application response time ultimately
Perhaps the most primary motivation to develop Ajax application is to have better user experience hence how to achieve the optimized response time becomes an important aspect in Ajax performance optimization. In this session, we will focus on discussing the improvement of the network transfer time and the JavaScript processing time as the server response is already generally well understood. We will use an Ajax framework case study to show how an Ajax optimization process can be used to optimize the performance. During the optimization process, we will demonstrate how to measure the performance, how to determine the bottlenecks and how to resolve the problems by applying various best practice. Various tools like NetBeans, Firebug, and YSlow will be illustrated to show when to use what and how to use them. The list of Ajax Performance tuning tips on combining CSS and JavaScript resources, setting the correct headers, using minifed JavaScript, GZip contents, and Strategically placing of CSS links and JavaScript tags will be discussed in the session.
Intermediate level Ajax and Enterprise developers can really benefit from this session.
After the session, the audience will be able to:
-apply Ajax Performance Optimization process
-choose the right tool and use them
-lleverage various best practice and performance tuning tips
-improve their Ajax application response time ultimately
Session presented at Oracle Developer Live - MySQL, 2020. Recording available at https://developer.oracle.com/developer-live/mysql/
Abstract:
MySQL Shell is the new, advanced command-line client and editor for MySQL. It sends SQL statements to MySQL server, supports both the classic MySQL protocol and the newer X protocol, and provides scripting capabilities for JavaScript and Python. But there's more to MySQL Shell than meets the eye. It delivers a natural and powerful interface for all DevOps tasks related to MySQL by providing APIs for development and administration. This session covers MySQL Shell's core features, along with demonstrations of how to use the various APIs and how to extend MySQL Shell. We’ll address the regular interaction with databases, the built-in tools that make DBAs and developers’ lives easier, the easy and flawless set up of HA architectures, and the plugins and extensions framework.
Lecture on CodeIgniter, # OSS Essential Training Program at Chittagong University of Engineering Technology, February 2008, http://bdosdn.org/wsatcuet.php
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
2. •Functions in PHP
•PHP Form
•Post And Get Method
•Usage of PHPMYADMIN
•Making Database
•MYSQL
•PHP data base connectivity
3. Functions are the group of statements that you can execute as a
single unit. Function definations are the lines of code that make up a
function
The syntax for defining a function is:
<?php
function name function(parameters) {
statements;}
?>
There are two types of functions.
1. Built-in functions.
2. User defined functions.
4. PHP has lots of built-in functions that we use all the time.
Some of the function are given below:
•PHP Array Functions
•PHP Calendar Functions
•PHP File System Functions
•PHP MySQL Functions
•Math functions
5. These functions allow you to interact with and manipulate arrays in
various ways. Arrays are essential for storing, managing, and operating on
sets of variables. Some Array Functions are:
Array(), Array push(), Array pop() etc.
<html>
<body>
<?php
$cars=array("Volvo","BMW","Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
</body>
</html>
7. The calendar extension presents a series of functions to simplify converting
between different calendar formats. Some PHP Calendar Functions are:
Cal info(), Cal days in month() etc.
<html>
<body>
<?php
print_r(cal_info(0));
?>
</body>
</html>
9. The filesystem functions are used to access and manipulate the filesystem
PHP provides you all the posible functions you may need to manipulate a
file.
List:
Copy(), delete(), file(), filetype() etc
10. These are functions dealing with MySQL handling and logging or to control
the MySQL through PHP functions.
List:
mysql_close(), mysql_connect() etc.
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
11. The math functions can handle values within the range of integer and
float types.
List:
hexdec(), sqrt(), sin() etc
<?php
echo hexdec("1e") . "<br>";
echo hexdec("a") . "<br>";
echo hexdec("11ff") . "<br>";
echo hexdec("cceeff");
?>
13. A user defined function is a user-defined set of commands that
are carried out when the function is called.
Function functionName()
{
code to be executed;
}
•A function should start with keyword function and all the function code
should be put inside { and } brace.
•A function name can start with a letter or underscore not a number.
•The function names are case-insensitive.
14. •Information can be passed to functions through arguments. An argument
is just like a variable.
•Arguments are specified after the function name, inside the parentheses.
•You can add as many arguments as you want, just separate them with a
comma.
15. <?php
function say_hello() {
echo “<p>Hello everybody!</p>”;
}
say_hello();
Function writeMSg() {
Echo “How are You?”;
}
writeMsg();
?>
17. <?php
function familyName($fname,$year)
{
echo “Name of Person is $fname. Born in $year <br>";
}
familyName(“Zeeshan Ahmed","1993");
familyName(“Abdul wahab","1992");
familyName(“Rashid Nawaz","1993");
familyName(“Saad Sattar","1991")
?>
18. If we call the function setHeight() without arguments it takes
the default value as argument:
<?php
function setHeight($minheight=50)
{
echo "The height is : $minheight <br>";
}
setHeight(350);
setHeight(); // will use the default value of 50
setHeight(135);
setHeight(80);
?>
19. When you create a form you have two choices for the METHOD
attribute. You can use one of the following two methods to pass
information between pages.
• GET method
• POST method
They both pass the data entered into the form along with the
form field name to the web server.
20. Information sent from a form with the GET method is visible to
everyone (all variable names and values are displayed in the URL). GET also
has limits on the amount of information to send. The limitation is about
2000 characters. However, because the variables are displayed in the URL,
it is possible to bookmark the page. This can be useful in some cases.
GET should NEVER be used for sending passwords or other sensitive
information!
22. 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.
However, because the variables are not displayed in the URL, it is
not possible to bookmark the page.
Developers prefer POST for sending form data.
24. Both GET and POST create an array (e.g. array( key => value, key2 =>
value2, key3 => value3, ...)). This array holds key/value pairs, where keys
are the names of the form controls and values are the input data from
the user.
Both GET and POST are treated as $_GET and $_POST. These are
superglobals, which means that they are always accessible, regardless of
scope - and you can access them from any function, class or file without
having to do anything special.
$_GET is an array of variables passed to the current script via the URL
parameters.
$_POST is an array of variables passed to the current script via the HTTP
POST method.
25. •PhpMyAdmin is a handy, graphical administration tool written in php for
creating and managing MySQL databases , using a web user interface.
•The interface is straight-forward and easy to learn and it allows users to
execute SQL queries manually.
•It is also open source, so you can download and use it for free.
26. •Create, drop, browse and modify databases.
•Perform maintenance on databases.
•Run query operations, drop, create, update, check, repair tables and
more.
•Manage MySQL users and privileges.
27.
28. You can access phpMyAdmin directly visiting the following URL;
http://localhost/phpMyAdmin
Or your server ip address
http://127.0.01/phpmyadmin
29.
30.
31.
32.
33.
34. MySQL also called "My Sequel" is the world's second most widely
used open-source relational database management system (RDBMS).
MySQL is a relational database management system (RDBMS), with
no GUI tools to administer MySQL databases or manage data contained
within the databases.
Users may use the included command line tools, or use MySQL "front-
ends", desktop software and web applications that create and manage
MySQL databases, build database structures, back up data, and work
with data records.
The official set of MySQL front-end tools, MySQL Workbench is actively
developed by Oracle, and is freely available for use.
35. The official MySQlworkbench is a free integrated environment
developed by MySQL , that enables users to graphically administer
MySQL databases and visually design database structures. MySQL
Workbench replaces the previous package of software, MYSQL GUI
Table. Similar to other third-party packages, but still considered the
authoritative MySQL front end, MySQL Workbench lets users
manage database design & modeling, SQL development (replacing
MySQL Query Browser) and Database administration (replacing
MySQL Administrator).
MySQL Workbench is available in two editions, the regular Free and
open source Community Edition which may be downloaded from
the MySQL website, and the proprietary Standard Edition which
extends and improves the feature set of the Community Edition.
36. The create user statement will create a new Mysql user account. But it have no
privileges. To create user you must have create user privilege or insert privilege for
mysql Database.
Create user ‘username’@’servername’ identified by ‘Password’;
The Drop user statement will drop one or more user accounts and their
privileges.to use this statement you must have global create privileges or delete
privilege for the mysql database.
Drop user ‘username’@’servername’;
37. The Grant statement grant privileges to the Mysql user account.to use grant
you must have the grant privilege or the privilege that you are granting.
Note: if the username describe in the grant option does not already exist.grant
may create it under the describes conditions.
Grant all on * . * to ‘username’@’servername’ ;
Grant select on * . * to ‘username’@’servername’ ;
Grant select on DB.* to ‘username’@’servername’ ;
Grant select, insert on DB.TB1 to ‘username’@’servername’ ;
Grant insert (c1,c2) on DB.TB1 to ‘username’@’servername’ ;
38. The Rename user statement rename the existing Mysql accounts.to use it you
must have the global create privilege or update privilege for Mysql Database.
An error occurs if any old account does not exist or any new account exists.
Rename cause the privileges held by the old user to be those held by new user.
Rename user does not drop or invalidate the databases or object s within them
created by the old user
Rename user ‘Existing name’@’servername’ to ‘new name’@’servername’;
39. The Revoke statement enable administrators to revoke
privileges from MySQL users.
To use the revoke statement you must have the grant
option and the privilege that you are revoking
Revoke all privileges, grant option from ‘user’@
’servername’;
Revoke select on * . * from ‘user’@ ’servername’;
40. Set Password statement is used to assign password to the existing
Mysql users
If the password is specified using the password function the password is given to the
function as argument,wwhich hash the password and return the encrypted password
41. SQL stands for Structured Query Language.
It is the most commonly used relational database language today.
SQL works with a variety of different programming languages, such
as Visual Basic.
Includes data definition language (DDL), statements that specify
and modify database schemas.
Includes a data manipulation language (DML), statements that
manipulate database content.
SQL data is case-sensitive, SQL commands are not.
42. SQL Must be embedded in a programming language, or used with a
Programming like VB
SQL is a free form language so there is no limit to the the number of
words per line or fixed line break.
Syntax statements, words or phrases are always in lower case; keywords
are in uppercase.
Not all versions are case sensitive!
43. CREATE TABLE: used to create a table.
ALTER TABLE: modifies a table after it was created.
DROP TABLE: removes a table from a database.
INSERT: adds new rows to a table.
UPDATE: modifies one or more attributes.
DELETE: deletes one or more rows from a table.
44. Things to consider before you create your table are:
The type of data.
The table name.
What column(s) will make up the primary key.
The names of the columns.
CREATE TABLE <table name>
( field1 datatype ( NOT NULL ), key type(optional)
field2 datatype ( NOT NULL ) );
45. To add or drop columns on existing tables.
ALTER TABLE <table name>
ADD attribute data type;
Or Modify attribute data type;
or
DROP COLUMN attribute;
46. Drop Table statement Has two options:
Specifies that any foreign key constraint violations that are
caused by dropping the table will cause the corresponding rows of the
related table to be deleted.
blocks the deletion of the table of any foreign key constraint
violations would be created.
DROP TABLE <table name> [ RESTRICT|CASCADE ];
47. Create table Departments
(id int not NULL primary key auto_increment,
Department char(15));
ALTER table Departments
Add batch varchar (20);
ALTER table Departments
Drop Column batch;
Drop TABLE Departments;
48. To insert a row into a table, it is necessary to have a value for
each attribute, and order matters.
Insert into Table(Attr1, Attr1, Attr1)values(NULL,’value1’,’value2’);
Insert into Departments(id, Department, Batch) values(NULL,’IT’,’5’);
49. To update the content of the table:
UPDATE <table name> SET <attr> = <value>
WHERE <selection condition>;
update Departments SET Batch=20 WHERE id=‘2’
Departments=‘physics’;
50. To delete rows from the table:
DELETE FROM <table name>
WHERE <condition>;
DELETE FROM Departments WHERE id=‘2’;
51. A basic SELECT statement includes 3 clauses
SELECT <attribute name> FROM <tables> WHERE <condition>
Specifies the
attributes that
are part of the
resulting relation
Specifies the
tables that serve
as the input to the
statement
Specifies the
selection condition,
including the join
condition.
52. Using a * in a select statement indicates that every attribute of the
input table is to be selected.
Example: SELECT * FROM Departments;
To get unique rows, type the keyword DISTINCT after SELECT.
Example: SELECT DISTINCT batch from Departments
53. Where clause is used to retrieve data from the table conditionally.it can
appear only after FROM clause.
Select Column From Table Where Condition;
Select * From Departments Where Batch=‘5’;
54. A join can be specified in the FROM clause which list the two
input relations and the WHERE clause which lists the join condition.
Students Departments
55. inner join = join
Select * from Department join student on id=dept_id;
56. left outer join = left join
Select * from Department left join student on id=dept_id;
57. right outer join = right join
Select * from Department right join student on id=dept _ id;
58. Pattern matching selection
Select * from Table where column like condition;
Select * from Departments where id like ‘%5’;
Select * from Departments where id like ‘_5’;
59. Ordered result selection
1) desc (descending order)
SELECT *
FROM departments
order by Batch desc;
2) asc (ascending order)
SELECT *
FROM departments
order by Batch asc;
60. The function to divide the tuples into groups and returns an aggregate
for each group.
Usually, it is an aggregate function’s companion
SELECT Batch, sum(Batch) as totalpatch
FROM Departments
group by Batch;
61. The substitute of WHERE for aggregate functions
Usually, it is an aggregate function’s companion
Example:
SELECT Batch, sum(Batch) as totalBatch
FROM Departments
group by Batch
having sum(Batch) > 10;
64. • PHP has the ability to access and manipulate any database that is
ODBC compliant
• PHP includes functionality that allows you to work directly with
different types of databases, without going through ODBC
65. Open a connection to a MySQL database server with the
mysql_connect() function
The mysql_connect() function returns a positive integer if it connects to
the database successfully or FALSE if it does not
Assign the return value from the mysql_connect() function to a variable
that you can use to access the database in your script
Close a connection to MySQL database server with the mysql_close()
function
66. The syntax for the mysql_connect()function is:
$connection = mysql_connect("host" , "user", "password");
if(!$connection)
{
die("Database connection filed: " .mysql_error());
}
The host argument specifies the host name or the where your MySQL
database server is installed
The user and pass arguments specify a MySQL account name and
password
67. This is also the syntax of connection
<?php
mysql_connect(“servername",“user",“password");
mysql_select_db (“database");
?>
68. This is also the syntax of connection
<?php
$server="localhost";
$user="root";
$pass=“password";
$database="school";
mysql_connect ($server , $user , $pass);
mysql_select _ db ($database);
?>
69. The connection will be closed automatically when the script ends.
To close the connection before, use the mysqli_close() function
<?php
$con=mysql_connect(“local host", “user", “password");
if (!$con)
{
echo "Failed to connect to MySQL: " . mysql_error();
}
mysqli_close($con);
?>
70. Reasons for not connecting to a database server include:
The database server is not running
Insufficient privileges to access the data source
Invalid username and/or password
The mysql_errno() and mysql_error() fuction used to show error
The mysql_errno() and mysql_error() functions return the results of
the previous mysql() function
71. The mysql_errno() function returns the error code from the last attempted
MySQL function call or 0 if no error occurred
<?php
$con = mysql_connect("localhost","root","Rashid0300");
if (!$con)
{ die('Could not connect: ' . mysql_errno()); }
mysql_close($con);
?>
72. The mysql_error() — Returns the text of the error message from previous
MySQL operation
<?php
$con = mysql_connect("localhost","root","Rashid0300");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_close($con);
?>
73. The syntax for the mysql_select_db() function is:
◦ mysql_select_db(database , connection);
The function returns a value of true if it successfully selects a database
or false if it does not
<?php
$db_select= mysql_select_db("WIDGET_CORP",$connection);
if(!$db_select)
{ die("Database not found: " .mysql_error()); }
?>