Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)

Slides:



Advertisements
Similar presentations
Building Database Relationships
Advertisements

Agenda Web Application Web Page development WAMP
Intermediate PHP & MySQL
ADVM420- Class #4 Web Design with PHP and MySQL Adding and Listing from a MySQL Database.
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.
Chapter 3. Table have many uses in a HTML design but are mostly used for the organization of your web site. Tables also give vertical and horizontal structure.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
ACM Web Development Workshop - PHP By Luis Torres.
© 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.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
1 Chapter 8 – Working with Databases spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
INTERNET APPLICATION DEVELOPMENT For More visit:
Create an online booking system (login/registration)
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
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.
PHP meets MySQL.
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.
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.
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.
Website Development with PHP and MySQL Saving Data.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
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.
HTML Concepts and Techniques Fifth Edition Chapter 4 Creating Tables in a Web Site.
MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which.
PART 2 INTRODUCTION TO DYNAMIC WEB CONTENT AND PHP.
Setting up Dreamweaver to use your local WAMP testing Server
CHAPTER 10 PHP MySQL Database
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
CSC 2720 Building Web Applications Accessing MySQL from PHP.
MySQL MySQL and PHP – interacting with a database.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Intro to APACHE, MySQL, and PHP & freely available (hackable) Packages Aonghus Sugrue 04 Oct 2012.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
This is the software we will use to load our html page up to the server. You can download a copy for home if you want to.
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.
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.
WampServer 2 Installation WAMP is a solution stack of open source programs used together to run dynamic Web sites or servers Most common expansion:  Windows,
Intro to WordPress (Using XAMPP)
IS1500: Introduction to Web Development
Introduction to Web programming
Web Design and Development
Web Design and Development
Database application MySQL Database and PhpMyAdmin
Introduction to Web programming
Website Development Basics with PHP MySQL
Introduction to Web programming
PHP Programming Using Cloud 9 IDE.
Presentation transcript:

Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)

Stack System In order to develop a web page which runs off a back end data base you will need to have a stack system in place, e.g. It is possible to create a stack on a standalone PC or server by installing WAMP Server (freely available as a download); WAMP works on top of Windows. WAMP has Apache web server, MySQL database, and PHP PHP scripting language MySQL database Apache web server Windows 7 operating system

Download WAMP Download WAMP server ( install. By default it places a folder www inside the wamp folder on the C: drive

Make sure WAMP is running There should be a green W icon in the notification tray in the lower right of the screen. A green icon means the WAMP server is running. If it is red it is turned off. If it is orange, there may be a problem (e.g. another server already running, an application using the port). You can also run WAMP server by choosing Programs > WampServer > Start WampServer

phpMyAdmin Open a web browser and type localhost (the default name for a home web server URL address). You should come up with a screen:

phpMyAdmin Click phpmyadmin The phpmyadmin database screen should appear The first time you use it, the default username is root, with no password Enter the username root and click Go

phpMyAdmin The MySQL database should open. Click the databases tab Enter simpledata for the name of the new database and click Create

phpMyAdmin Decide on the database structure: it is usually best to sketch this. Data is contained in a table called feedback Use the sketch below (an example): The example table has 3 columns, each column representing a field name The rows are the records representing the data (examples shown)

phpMyAdmin A list of databases appears with simpledata in the list Create a table by clicking the name of the database (simpledata)

phpMyAdmin Type a name for the table: feedback Enter 3 as the number of columns (fields) Click Go (on the far right of the window)

phpMyAdmin The table structure should appear like below: The 3 columns are now represented by the 3 rows now

phpMyAdmin Enter the names for the first column. This represents the fields Enter the Type and Length/Values, then click Save (lower right):

phpMyAdmin Some common types include: INT = Integer (a number without a decimal point) CHAR = Characters (can hold text up to a specific length) VARCHAR = Variable Length Characters (a text field that is not a fixed width). TEXT = For holding large amounts of text. DATE = Can only hold dates. DATETIME = Can hold both a date and a time.

phpMyAdmin You should see the name feedback as the name of the table, and simpledata as the name of the database To add data click Insert along the row of tabs

phpMyAdmin Add some values, e.g. Click Go

phpMyAdmin Set one of the rows as a primary key. Click Primary on the row name This sets the name as the primary key. The primary key of a table uniquely identifies each record in the table. Every database table should have one or more columns designated as the primary key. When click, the primary key looks greyed out

phpMyAdmin Click Browse to view the data in the table:

The next step can be done in Dreamweaver Accessing the database using PHP

Before we can access data in a database, we must open a connection to the MySQL server. In PHP, this is done with the mysqli_connect() function. Syntax: mysqli_connect(host,username,password,dbname); The details you are using (from our initial plan): mysqli_connect(“locahost”,”root”,””,”simpledata”); simpledata

Accessing the database using PHP Create a new PHP file, e.g. in Dreamweaver. Enter some PHP script. 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!

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

Preview web page in browser You have used MySQL (Structured Query Language) with PHP to access a database. If you open the page in a browser and view source (right click the web page) you should see something like this: Notice your code entered in Dreamweaver is not shown to the end user This helps with security, as the database details are not shown

Add HTML tags (elements) When viewing source the HTML is very basic. Try adding HTML elements (tags), e.g.,,,, etc. \n is an escape character and allows line breaks in the code

Edit Database Add new records to the database in PHPmyAdmin Test the output in Dreamweaver

Edit Database Click Browse to see added rows:

Back to Dreamweaver Refresh the page in Dreamweaver

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?