MySQL MySQL and PHP – interacting with a database.

Slides:



Advertisements
Similar presentations
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.
Advertisements

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
NMD202 Web Scripting Week5. What we will cover today PHPmyAdmin Debugging – using print_r Modifying Data PHP (cont.) 4D Methodology File and IO operations.
Objectives Connect to MySQL from PHP
Dynamic Web site With PHP and MySQL. MySQL The combination of MySQL database and PHP scripting language is optimum for building dynamic websites. MySQL.
PHP-Fusion. Introduction PHP-Fusion is a lightweight open source content management system (CMS) written in PHP. PHP-Fusion utilizes a MySQL database.
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.
© 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.
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 &
INTERNET APPLICATION DEVELOPMENT For More visit:
MySQL + PHP.  Introduction Before you actually start building your database scripts, you must have a database to place information into and read it from.
Create an online booking system (login/registration)
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
MySQL + PHP.  Introduction Before you actually start building your database scripts, you must have a database to place information into and read it from.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
© 2003 By Default! A Free sample background from Slide 1 Week 2  Free PHP Hosting Setup  PHP Backend  Backend Security 
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.
Lec_6 Manipulating MySQL Databases with PHP PHP Programming with MySQL.
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.
PHP with MySQL 1.
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.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
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.
Enterprise PHP – Reading Data from a DB Reading Data from a relational database in PHP Nic Shulver, FCES, Staffordshire University Using the SQLi interface.
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.
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.
PHP “Personal Home Page Hypertext Pre-processor” (a recursive acronym) Allows you to create dynamic web pages and link web pages to a database.
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.
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.
Setting up Dreamweaver to use your local WAMP testing Server
CHAPTER 10 PHP MySQL Database
>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.
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.
Intro to APACHE, MySQL, and PHP & freely available (hackable) Packages Aonghus Sugrue 04 Oct 2012.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
13 – PHP MySQL Connection Informatics Department Parahyangan Catholic University.
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.
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.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free, and efficient alternative.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
PHP: MySQL Lecture 14 Kanida Sinmai
Intro to WordPress (Using XAMPP)
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
IS1500: Introduction to Web Development
Web Design and Development
Web Design and Development
Introduction to Web programming
Website Development Basics with PHP MySQL
Easy Way to Reset WordPress Admin Password on Localhost? Guided By: WPGLOBALSUPPORTWPGLOBALSUPPORT.
Introduction to Web programming
MySQL Web Application Connecting to a MySQL database
Tutorial 6 PHP & MySQL Li Xu
MySQL Web Application Connecting to a MySQL database
Introduction to Web programming
Presentation transcript:

MySQL MySQL and PHP – interacting with a database

Stack System It is assumed a stack system has been created with a testing server running, and a database linked to a web page, e.g. PHP scripting language MySQL database Apache web server Windows 7 operating system WAMP

http;//localhost/phpmyadmin Username is root If your database is for a live web project use a password and different username for security As this is a testing server used locally, there is no password, just the username admin Can log on to MySQL with administrator rights

Database simpledata created earlier (example) Table feedback created inside simpledata

PHPMyAdmin (MySQL) settings Name of host: localhost (default name for most testing servers) Login: MySQL database (PHPMyAdmin) login name: root (default name which you would change if using the website live) Password: leave blank Database name: simpledata Table name (inside database): feedback. If you experience problems you can go back to the other PowerPoint presentation showing you how to set up a MySQL database in PHPMyAdmin. Access PHPMyAdmin from a web page in Dreamweaver.

Database linked to web page with PHP The following opens the connection to the server and database simpledata.php <?php // Create connection $con=mysqli_connect("localhost","root","","simpledata"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: ". mysqli_connect_error(); } ?> An If statement checks for any errors and displays an error message if the connection fails. No error messages mean it works! Password (blank) Login name to MySQLDatabase name

Accessing the database using PHP PHP script created in Dreamweaver.

Presenting a database using PHP The SELECT statement is used to select data from a database: Add the following PHP <?php $result = mysqli_query($con,"SELECT * FROM feedback"); while($row = mysqli_fetch_array($result)) { echo $row['name']. " ". $row['rating']; echo " "; } mysqli_close($con); ?> The data from the table feedback is returned by the mysqli_query() function and stored in the $result variable. The mysqli_fetch_array() function returns the first row from the table as an array variable &row. The while loop allows mysqli_fetch_array() to return the next row in the recordset. The while loop loops through all the rows. To echo the value of each row, we use the PHP $row array variable ($row['FirstName'] and $row['LastName']).

Presenting a database using PHP The source code and live view will look similar to this

Selecting and changing a database PHPMyAdmin MYSQL and Dreamweaver

Accessing using MySQL/PHP Specify a range of MySQL commands to interact with a database simpledata from PHP (in Dreamweaver) Add new records to the table feedback Delete a record from the table feedback List records from the database feedback Amend data from the database feedback and list Select a range of data using comparitors (e.g. < less than) International Cheese (new database) Create a new database called cheese, using PHP Create a new table international_cheese.php Add records to the table (e.g. name, country, strength, image, in_stock) Output data from table using PHP. Save the web page as cheese.php

Create a new database If the database cheese does not exist you can create it as shown below.

Editing MySQL You can change the PHP and edit the MySQL code to be more selective in the process. For more info on MySQL, check E.g. to select from database only records where the name is “Sam Lowry” change the line $result = mysqli_query($con,"SELECT * FROM feedback"); To $result = mysqli_query($con,"SELECT * FROM feedback WHERE name=‘Sam Lowry'");

Editing MySQL

MySQL This is the basics of using MySQL. Many websites use MySQL, including Google search engine. MySQL is freely downloadable, light and powerful, and simple to use once you know it more. Like PHP there are a lot of help forums and web pages providing support and guidance. Many Content Management Systems (CMS), e.g. WordPress, use PHP with MySQL Try finding out more about MySQL. Where else is it used?