NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.

Slides:



Advertisements
Similar presentations
PHP: Date() Function The PHP date() function formats a timestamp to a more readable date and time.
Advertisements

PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
NMD202 Web Scripting Week3. What we will cover today Assignment 1 Database Concepts MySQL Exercises Server side validation Exercises.
NMD202 Web Scripting Week5. What we will cover today PHPmyAdmin Debugging – using print_r Modifying Data PHP (cont.) 4D Methodology File and IO operations.
Manipulating MySQL Databases with PHP. PHP and mySQL2 Objectives Connect to MySQL from PHP Learn how to handle MySQL errors Execute SQL statements with.
Objectives Connect to MySQL from PHP
Multiple Tiers in Action
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
Intermediate PHP & MySQL
PHP and MySQL Web Development tMyn1 PHP and MySQL Web Development When you install PHP, you can select from a number of extensions. The MySQL support in.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Application Sketch home.htm delete.php updateform.php display.php insert.php insertform.htm update.php Data Base Hyperlink Information exchange with database.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP Part 2.
INTERNET APPLICATION DEVELOPMENT Practical on Sessions.
Technology & Management Club Development Software Overview.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Creating PHPs to Insert, Update, and Delete Data CS 320.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with.
Copyright 2007 Byrne Reese. Distributed under Creative Commons, share and share alike with attribution. Intermediate Perl Programming Class Three Instructor:
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
CSC 405: Web Application Engineering II8.1 Web programming using PHP What have we learnt? What have we learnt? Underlying technologies of database supported.
MySQL MySQL and PHP – interacting with a database.
PHP AND SQL SERVER: QUERIES IST 210: Organization of Data IST210 1.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Introduction to Dynamic Web Programming
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Relational database and SQL MySQL LAMP SQL queries
Introduction to Web programming
BASIC PHP and MYSQL Edward S. Flores.
PHP Overview PHP: Hypertext Preprocessor Server-Side Scripting
Database Driven Websites
Tutorial 6 PHP & MySQL Li Xu
Introduction to Web programming
Presentation transcript:

NMD202 Web Scripting Week5

What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1

Displaying Dynamic Pages A database driven website allows the content of the site to live in a database Web Browser Web Server PHP MySQL Request Response Request Data Provides Recordset

Displaying Dynamic Pages PHP has a client built into the Language. You can run all the operation available in MySQL from within PHP

Displaying Dynamic Pages Connect to the Database: $conn = mysql_connect(address,username,password); $conn will hold a connection identifier after the operation is successful or false if connection fails

Displaying Dynamic Pages Select the Database: mysql_select_db(databaseName,$conn); $conn is the connection identifier provided by the connection statement

Displaying Dynamic Pages Query the Database: $result = mysql_query(query,$conn); $conn is the connection identifier provided by the connection statement $result will hold the result of the query, or false if query fails

Displaying Dynamic Pages Handling errors Whenever your code relies on third party systems (ie:MySQL) you should always handle unforseen errors. $conn = mysql_connect(address,username,password); If (!$conn) { echo “ Could not connect ”; die(); }

Displaying Dynamic Pages Handling errors If (! mysql_select_db($databaseName,$conn) { echo “ Could not locate”.$ databaseName.” ”; die(); }

Displaying Dynamic Pages Handling errors $result = mysql_query(query,$conn); If (!$result) { die (“ Error performing query:”.mysql_error().” ”); }

Displaying Dynamic Pages Handling Resultsets $result = mysql_query(query,$conn); If (!$result) { die (“ Error performing query:”.mysql_error().” ”); } while ($row = mysql_fetch_array($result)) { // $row will hold an assoc array with the columns names as keys echo $row[“studentName”]; }

Displaying Dynamic Pages Keep config information separate: configuration.php $mySQLhost = “ ”; $userName = “root”; $password = “”; $database = databaseName; Include configuration.php from your main file, if using inside a function don’t forget to include the keyword global

Exercise Display all students loaded in previous class as a table with all the attributes (name, , etc)

Modifying Data Inserting data (example): Form is submitted Validation is performed Query is built based on submitted data (data should be sanitized) Query is performed Feedback is given to the user

Modifying Data Editing Data (example): Id record to edit is passed through the querystring Select query is executed to get the required record Form is built pre populating fields with record info Form is submitted Validation is performed Query is built based on submitted data (data should be sanitized) Query is performed Feedback is given to the user

Modifying Data Deleting Data (example): Id record to delete is passed through the querystring Query is built based on id (data should be sanitized) Query is performed Feedback is given to the user

Exercise Build a complete set of screens to insert, update, display and delete the students records. On the display table insert two more columns with links to the delete and edit pages, providing the id of the record. Split the logical parts into separate php files: display.php, edit.php, insert.php, delete.php, configuration.php

Assignment 1 Project Brief ER Diagram