OBJECTIVES Learn how to view data using SQL and PHP Learn how to add new data using SQL and PHP PHP+SQL: View and Adding,

Slides:



Advertisements
Similar presentations
Web Database Programming Connecting Database to Web.
Advertisements

Creating a Form on a Web Page
Database Connectivity in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section PHP and MySQL.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
PHP : Hypertext Preprocessor
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.
U:/msu/course/cse/103 Day 25, Slide 1 Back-up PHP Files If you have not yet passed the 3.0 BT, make back-up copies of ALL.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
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,
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
08/09/2015 Intro PHP & MySQL 1 Helen Hastie Room: EM2.44 Material available on Vision (modified from slides by Monica Farrow) F27DB Introduction.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
INTERNET APPLICATION DEVELOPMENT For More visit:
Create an online booking system (login/registration)
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
Week 7. Lecture 3 PHP Forms. PHP forms In part 2 of this course, we discussed html forms, php form is similar. Lets do a quick recap of the things we.
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 meets MySQL.
HTML Concepts and Techniques Fourth Edition Project 7 Creating a Form on a Web Page.
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.
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.
MySQL and PHP 3 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
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.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
Technology & Management Club Development Software Overview.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
CSC 240 (Blum)1 Forms and Importing Data in Access.
PHP - MySQL Connection 8 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
HTML, PHP, and MySQL: Putting It All Together. Making a Form Input tags Types: “text” “radio” “checkboxes” “submit”
HTML and FORMS.  A form is an area that can contain form elements.  Form elements are elements that allow the user to enter information (like text fields,
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.
PHP Form Introduction Getting User Information Text Input.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
Retrieving data from MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
13. PHP: Insert, View Data. M. Udin Harun Al Rasyid, S.Kom, Ph.D Desain dan Pemrograman.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
1 Database Systems Introduction to Microsoft Access Part 2.
PHP and Mysql Database. PHP and Database Mysql – popular open-source database management system PHP usually works with Mysql for web-based database applications.
1 DIG 3134 – Lecture 14 MySQL and PHP Play Together Michael Moshell University of Central Florida Media Software Design.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
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)
PHP: MySQL. PHP Connect to MySQL PHP 5 and later can work with a MySQL database using: – MySQLi extension (the "i" stands for improved) – PDO (PHP Data.
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.
CSC 2720 Building Web Applications Accessing MySQL from PHP.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
PHP with MYSQL Please use speaker notes for additional information!
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
SQL MODELER - OPEN There are Three Ways to open the SQL Modeler
Introduction to Web programming
MIS2502: Data Analytics MySQL and SQL Workbench
Server-Side Processing II
PHP: Combo box FdSc Module 109 Server side scripting and
Introduction to Web programming
Presentation transcript:

OBJECTIVES Learn how to view data using SQL and PHP Learn how to add new data using SQL and PHP PHP+SQL: View and Adding,

Mechanism for HTLM PHP and SQL HTML FORM with textboxes, radio buttons, etc. PHP gets important values, and executes SQL commands SUBMIT BUTTON

Searching and viewing data  Check database connection  Get the value string from the previous form  Process data: (in this process, we use the select function)  Give feedback to user.

Viewing Search Data This HTML form has a textbox where the user enters a search string, and a button to send data We catch the data from the HTML’s textbox using either $_POST / $_GET SUBMIT BUTTON Use that data as our value for the search String. Use the SELECT function to view data Execute it using PHP

Remember the SELECT command in SQL>? SELECT SELECT * FROM table_name WHERE [Conditions] Eg. SELECT * INTO friends WHERE Lastname = ‘Gener’;

Remember how we catch data? message: message: <?php $input = $_POST[‘lastname’]; echo “You said: $input ”; ?> <?php $input = $_POST[‘lastname’]; echo “You said: $input ”; ?> Html_form.htmlResult_form.php

Remember the SQL/DB Connector? 1. <?php 2. $connection = mysql_connect(‘localhost’,’root’,’password’); 3. mysql_select_db('friends') ; 4. $query = 'Select * FROM names'; 5. $result = mysql_query($query); 6. echo " "; 7. if(mysql_num_rows($result) > 0) 8. { 9. while($row = mysql_fetch_row($result)) 10. { 11. echo " $row[1], $row[2] "; 12. } 13. } 14. echo " "; 15. mysql_free_result($result); 16. mysql_close($connection); 17. ?> 1. <?php 2. $connection = mysql_connect(‘localhost’,’root’,’password’); 3. mysql_select_db('friends') ; 4. $query = 'Select * FROM names'; 5. $result = mysql_query($query); 6. echo " "; 7. if(mysql_num_rows($result) > 0) 8. { 9. while($row = mysql_fetch_row($result)) 10. { 11. echo " $row[1], $row[2] "; 12. } 13. } 14. echo " "; 15. mysql_free_result($result); 16. mysql_close($connection); 17. ?>

What to do? We need to integrate the Catching of Data and SQL/DB to PHP Connection Mechanism together.

Html_form.html message:

Result_form.php 1. <?php 2. $connection = mysql_connect(‘localhost’,’root’,’’); 3. mysql_select_db('friends') ; 4. $query = 'Select * FROM names'; 5. $result = mysql_query($query); 6. echo " "; 7. if(mysql_num_rows($result) > 0) 8. { 9. while($row = mysql_fetch_row($result)) 10. { 11. echo " $row[1], $row[2] "; 12. } 13. } 14. echo " "; 15. mysql_free_result($result); 16. mysql_close($connection); 17. ?>

Result_form.php improvement 1. <?php 2. $search_value = $_POST[‘lastname’]; 3. $connection = mysql_connect(‘localhost’,’root’,’’); 4. mysql_select_db('friends') ; 5. $query = “Select * FROM names where lastname LIKE ‘$search_value%’”; 6. $result = mysql_query($query); 7. echo " "; 8. if(mysql_num_rows($result) > 0) 9. { 10. while($row = mysql_fetch_row($result)) 11. { 12. echo " $row[1], $row[2] "; 13. } 14. } 15. else 16. { 17. echo “Record Not found!”; 18. } 19. echo " "; 20. mysql_free_result($result); 21. mysql_close($connection); 22. ?>

Step 2: Schema 1 st Page: The Site will Ask for the Lastname 1 st Page: The Site will Ask for the Lastname 2 nd Page: The Site will Show the Record using a loop 2 nd Page: The Site will Show the Record using a loop Does the record exist? Error Page: The Site give a feedback Error Page: The Site give a feedback False True

 Check database connection  Get the data from the previous form  Process data: (in this process, we use the insert function)  Give feedback to user. Inserting Data

Viewing Search Data This HTML form with all necessary form elements. We catch the data from the HTML’s textbox using either $_POST / $_GET SUBMIT BUTTON Use the INSERT function (SQL) to Insert Data to the Database Execute it using PHP

View, Add, Edit and Delete INSERT INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...) Eg. INSERT INTO friends (firstname,lastname) VALUES (‘Pancho’,’Trinidad’);

Html_form.html lastname: 5. firstname: 6. midname: 7. age: 8. gender: Male Female

Result_form.php //PART 1: Check Database and connect it to php <?php $search_value = $_POST[‘lastname’]; $connection = mysql_connect(‘localhost’,’root’,’’); mysql_select_db('friends') ;.

Result_form.php (cont). // get Data $firstname = $_POST[‘firstname’]; $lastname = $_POST[‘lastname’]; $midname = $_POST[‘midname’]; $age = $_POST[‘age’]; $gender = $_POST[‘sex’];.

Result_form.php (cont) // process data and run Sql $query = “INSERT into friends (lastname,firstname,midname,age,gender) values (‘$firstname’,’$lastname’,’$midname’,’age’, ‘gender’)”; $result = mysql_query($query); // give feedback Echo “Database Saved”; mysql_free_result($result); mysql_close($connection); ?>

Step 2: Schema 1 st Page: The page will Ask for the data using form elements 1 st Page: The page will Ask for the data using form elements 2 nd Page: The page will Insert records using SQL commands 2 nd Page: The page will Insert records using SQL commands The Page give a feedback

Assignment # 2 Make a Telephone Catalogue  Firstname  Lastname  Address_House_Number  Address_Street  Address_Barangay  Address_City  Telephone_number

Step 2: Schema Add Record Insert Record The Page give a feedback Look List Show all list The Page give a feedback Search Record Get Search Key Search Record If record exist? Show Record The Page give a feedback Telephone Directory Menu

Assignment # 2