13. PHP: Insert, View Data. M. Udin Harun Al Rasyid, S.Kom, Ph.D Desain dan Pemrograman.

Slides:



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

1 After completing this lesson, you will be able to: Create a database. Create a table using the Table Wizard. Create and modify a table in Design view.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
NMD202 Web Scripting Week5. What we will cover today PHPmyAdmin Debugging – using print_r Modifying Data PHP (cont.) 4D Methodology File and IO operations.
Project Description. Creating your dababase application with PHP It will be sufficient to have an application that accommodates all the need of the intended.
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 11 1 Microsoft Office Excel 2003 Tutorial 11 – Importing Data Into Excel.
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.
Programming Logic and Design Fourth Edition, Comprehensive
PHP and SQL Server: Queries IST2101. Project Report 4 SQL Queries Due Sunday, 4/5 at 11:59pm Instructions on how to access team webspace and SQL database.
15. User Authentication, Form Validation, Paging. M. Udin Harun Al Rasyid, S.Kom, Ph.D
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
PHP Forms and User Input The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
INTERNET APPLICATION DEVELOPMENT For More visit:
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.
DAT602 Database Application Development Lecture 14 HTML.
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:
Server-side Scripting Powering the webs favourite services.
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
PHP – MySQL Extensions. Table used in most examples CREATE TABLE product ( rowID INT NOT NULL AUTO_INCREMENT, productid VARCHAR(8) NOT NULL, name VARCHAR(25)
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
First Screen : First window form will always remain open, for the user to select menu options. 1.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Mail merge letters are used to send the same or similar documents to many different people. Since they contain the recipient’s name, address, and other.
PHP meets MySQL.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
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.
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.
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.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Session 7: Getting PHP to Talk to MySQL. Objectives Connecting to the Database Building & Executing the SQL SELECT Query Fetching & Displaying the data.
14. Uploading Files to MySQL Database. M. Udin Harun Al Rasyid, S.Kom, Ph.D Desain dan.
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.
1 Committed to Shaping the Next Generation of IT Experts. Chapter 1- Introduction to Access: What is a Database? Robert Grauer and Maryann Barber Exploring.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
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.
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
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)
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Personal Oracle8i Create a new user Create a new table Enter data into a new table Export & import data Start and exit SQL Plus SQL Plus Syntax.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
WAMP Server Installatin Shiyun Wen. WAMP Server Installation  WAMP Server is an integrated installation of Apache, MySQL, and PHP for Windows. Following.
Database to HTML and Back again A programmers tale.
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,
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Databases.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Database application MySQL Database and PhpMyAdmin
BASIC PHP and MYSQL Edward S. Flores.
HTML Forms and User Input
Presentation transcript:

13. PHP: Insert, View Data. M. Udin Harun Al Rasyid, S.Kom, Ph.D Desain dan Pemrograman Web

Table of Contents PHP MySQL insert data PHP MySQL view data PHP MySQL edit data PHP MySQL delete data

PHP MySQL: Inserting Data To insert data into database, use the sintaks: INSERT INTO nama_table (field1,field2,...) VALUES ('data1','data2',...) If the field parameter do not declare, the amount of the inserting data must have the same as the amount of the table field.

Example

Result View From Phpmyadmin

PHP MySQL: Creating Form Insert Data In order to make this input data is 'user friendly', you can make a HTML form for input data

Result

The HTML form will send two variable, $name and $address variable, into input.php file as describe in the ACTION parameter of FORM HTML.

After you have already made input.php, fill the input data and then click the sent button such as:

Result

View the result from phpmyadmin

PHP MySQL: Display Data In looking for one or more data in the database, you can use syntax such as: SELECT field1,field2,... FROM name_table WHERE condition1,condition2,... ORDER BY name_field If field displayed is all field from the table, so all of the name field itself does not have to be declared but it is enough to change with the sign * then all field will be accessed.

ORDER BY parameter shows the data that is organized based on which field you choose. The default sequence is from the smallest one (number sequence), from A-Z (letter sequence), and from the first data to the last data (time sequence). You can reverse these sequence by adding DESC attribute.

Example

Result

Then, you can use DESC like $order = "SELECT * FROM data_employees ORDER BY name DESC" so the result will be:

PHP MySQL: mysql_fetch_row() Function Mysql_fetch_row() function takes the data from $result variable in per line. The first take is the top-ranking data line. The data that it takes is in the array shape where the element from array is the field of data table. For example, in the program of data_employees, the syntax of $row = mysql_fetch_row($result) will produce: and so on until the while order get the false value then the restarting will be stopped.

PHP MySQL: mysql_fetch_array() Function Beside using mysql_fetch_row() function in order to get the query result into database, you can also use mysql_fetch_array() function. It has the same function as mysql_fetch_row() function where the data reads line per line. The difference of both function is that the result of mysql_fetch_array() function is in the array assosiatif shape.

For example, if you use mysql_fetch_array() in the program of data_employees such as $row = mysql_fetch_array($result) will produce:

PHP MySQL: Editing data In editing the data, you can use the syntax as follow: For example, we will try to edit one of the data from data_employees table.

file: db.inc.php for connection database

file: edit.php for connection database

Result: edit.php

The picture above is edit.php file where this file will show overall data in the table, then there is edit menu in the last column. If you click the edit menu, it will bring the program to execute edit_form.php file. Edit_form.php file will show a form to edit the data which have been selected in the previous form. The mechanism is that the user choose one of the data that will be edited in the first form (edit.php file) by clicking the edit menu in the right column.

Edit_form.php:

Result edit_form.php By clicking the edit button, the program goes to the fourth program, edit_data.php file, which brings three variable such as $id variable which contains of employees number data, $name variable which contains of employees name data, and $address variable which contains of employees address.

In order to know whether the data is already change or not, the program is re-instructed to edit.php file with the order of header ("location:edit.php"). Here is the edit_data.php program file:

PHP MySQL: Deleting data In deleting the data, use the sintaks as follow: DELETE FROM name_table WHERE condition1,condition2,... As for example, we will add menu to delete the data in table edit data such as:

Delete menu will bring the program into delete.php file where it is used to delete the data which have been selected in the above form. Delete.php file as follow:

Finish