COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.

Slides:



Advertisements
Similar presentations
Building Database Relationships
Advertisements

DNR-322L & DNR-326.
© 2010 Delmar, Cengage Learning Chapter 1 Getting Started with Dreamweaver.
Install WordPress with Xampp. By With Thanks to: Rupesh Kumar.
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
1 Computing for Todays Lecture 22 Yumei Huo Fall 2006.
MySQL and PHP By Trevor Adams.
Creating and Publishing Your own website
Dynamic Web site With PHP and MySQL. MySQL The combination of MySQL database and PHP scripting language is optimum for building dynamic websites. MySQL.
Open Source Software WampServer Presented By Mr. R.Aravindhan.
This presentation will guide you though the initial stages of installation, through to producing your first report Click your mouse to advance the presentation.
OARE Module 3: OARE Portal.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Adobe Dreamweaver CS3 Revealed CHAPTER ONE: GETTING STARTED WITH DREAMWEAVER.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
CSCI 6962: Server-side Design and Programming
Session 5: Working with MySQL iNET Academy Open Source Web Development.
LIS651 lecture 7 PHP mySQL Thomas Krichel
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
INTRODUCTION TO FRONTPAGE. TOPICS TO BE DISCUSSED……….  Introduction Introduction  Features Features  Starting Front Page Starting Front Page  Components.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Creating a Web Site to Gather Data and Conduct Research.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Microsoft Office Access 2003 Số tiết: 30 tiết lý thuyết 60 tiết thực hành Giáo viên: Từ thị Xuân Hiền.
MySQL. MySQL is a Relational Database Management System (RDBMS) that runs as a server providing multiuser access to a number of databases. A third party.
Ways to manage DB in MySQL cs346. Six ways to CREATE and INSERT INTO tables Modelocalremotelocalremotewindow WhereMysql console Putty; Mysql console Mysql.
TxEIS Security A role-based solution October 2010.
1 Working with MS SQL Server Textbook Chapter 14.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Creating and Publishing Your own web site PC Version SEAS 001 Professor Ahmadi.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
PHP with MySQL 1.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Login to a Database (from a Webpage), Inserting data into a database from a form, getting data from database and display on Webpage Done by: Mashail Alsolamy.
2010/11 : [1]PHP with MySQLBuilding Web Applications using MySQL and PHP (W1) PHP with MySQL.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
WAMP Windows Apache MySQL and PHP i.e. “WAMP”. Why WAMP? WampServer is a Windows web development environment. It allows you to create and test web pages.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
WAMP Server Installatin Shiyun Wen. WAMP Server Installation  WAMP Server is an integrated installation of Apache, MySQL, and PHP for Windows. Following.
PART 2 INTRODUCTION TO DYNAMIC WEB CONTENT AND PHP.
Setting up Dreamweaver to use your local WAMP testing Server
>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
MySQL MySQL and PHP – interacting with a database.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
Joomla Awdhesh Kumar Singsys Pte Ltd. What is Joomla? Joomla is an award-winning content management system (CMS), which enables you to build Web sites.
Installing and Configuring Moodle. Download Download latest Windows Install package from Moodle.orgMoodle.org.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
XP Creating Web Pages with Microsoft Office
2nd year Computer Science & Engineer
Intro to WordPress (Using XAMPP)
Introduction to Dynamic Web Programming
Introduction to Web programming
Web Design and Development
Database application MySQL Database and PhpMyAdmin
BASIC PHP and MYSQL Edward S. Flores.
ISC440: Web Programming 2 Server-side Scripting PHP 3
Web Systems Development (CSC-215)
Lecturer: Yong Liu Contact me at:
PHP and Forms.
Tutorial 6 PHP & MySQL Li Xu
Presentation transcript:

COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL

Web + PHP + MySQL Apache PHP MySQL WAMP/MAMP  Required Tools Text Editor or a Program like Dreamweaver

Installing WAMP/MAMP  Windows: Download and Install WAMP Server  MAC: Download and Install MAMP  Leave all the settings as default except the browser (change to your preferred browser: I recommend Chrome, Firefox or Safari)  Once Installed, your files for this module need to be stored in the following folder (also applies to the lab machines): c:/wamp/www/ Task: Create a folder with your name inside this folder

Configuring WAMP  Start Wampserver: a red “w” icon should appear in your taskbar, it should go from red, to orange to green – once it is green we are ready to go

WAMP in Browser

home pop-up sql window databases manage users import data export db db status phpMyAdmin help mysql help phpMyAdmin interface

Creating the database From the main menu choose Databases In the create database field type in a name for your database. Leave the collation drop down box if you wish to use the default MySQL schema collation. Click Create.

Setup a new user To setup a new user login to access this database, click on Users in the main menu. Choose the Add User option under the list of available server users.

Setup a new user (cont.) In the section titled Login Information - type in a username, localhost and a password in the fields as shown. Optionally you can press the Generate button to create a random password for you.

Setup a new user (cont.)

Edit Privileges After the user is created, you can see it listed on the Users page. Click Edit Privileges to assign access to a specific database. Once again leave the Global Privileges section BLANK. Scroll down to the section titled Database-Specific Privileges. Username = “root” Password = “”

Edit Privileges (Cont.) Choose the database you want the user to be able to access from the list, and click GO.

Edit Privileges (Cont.) The following permissions are recommended for compatibility with most modern web-based software applications.

What is SQL?  Structured Query Language  Allows database operations  Retrieve data  Modify data  Insert new data  Remove data  Create and modify tables

MySQL – Database - Tables  A MySQL server is capable of storing many databases  A database is generally made of a collection of related tables  Each table will have a name that is unique within the database  A table (table name - student) contains records with data StudentIDForenameSurnameLevel AK123900TrevorAdams1 AB340948BobbyRatchet3 AC234887JohanDoex2

MySQL - Queries  A query performed on a database can result in data or some kind of status  Queries can come in the following forms: SELECT – extracting data UPDATE – updates data DELETE – deletes data INSERT – inserts data  SELECT StudentID FROM Student StudentID AK AB AC StudentIDForenameSurnameLevel AK123900TrevorAdams1 AB340948BobbyRatchet3 AC234887JohanDoex2

Connecting to databases  One of the most common tasks when working with dynamic webpages is connecting to a database which holds the content of the page  PHP has several libraries that allows for communication with many different databases  We will be using the mysqli library  Most functions start with mysqli_ and then the name of the function

Opening a connection  You will need: The address to the database server A username with privileges to access the table you require The username associated password The name of the database you are connecting  mysqli_connect(…..): returns a link to the host using username and password authentication. //Connect to server and database $conn = mysqli_connect("localhost", “username", “password", “database");

Executing Queries  mysqli_query(link, query) is used to run a query on the database server. Returns a result object. $result = mysqli_query ( $conn, “SELECT * FROM student” );  Queries can be constructed as strings and then the string variable can be used on the mysqli_query command: $my_query = "SELECT * FROM student"; $result = mysqli_query ( $link, $query );

Working with the result from the query  You can think of a result set as the TABLE that holds the result  You need to read the rows from that table individually using mysqli_fetch_array  Using this function, the array returned can be numerically indexed or associative! or numerically indexed and associate $row = mysqli_fetch_array($result, MYSQLI_NUM); // $row[0], $row[1] $row = mysqli_fetch_array($result, MYSQLI_ASSOC); // $row[“StudentID"], $row[“Forename"] $row = mysqli_fetch_array($result, MYSQLI_BOTH); // $row[0], $row[“Forename"]  If there are no more rows, the function returns FALSE StudentIDForenameSurnameLevel AK123900TrevorAdams1 $row

Keeping it tidy  Once you have completed your work with the database, there are two things you should do: Free the results Close the connection to the server.  Freeing the results can be optional: On closing the connection, the results are automatically freed  If you are planning to run further queries on the same connection, it is good practice to free the previous result set. mysqli_free_result($result);  To close the connection you use mysqli_close($conn);

Working with databases – key steps  Design the DB – Create the DB on PHPMyAdmin  Design and Create the HTML  Create a connection  Select the table  Run the query  Select/Insert/Delete other SQL associated tasks  Display Results as needed  Close the connection