MySQL PHP Web Technology. Logging in to Command Line Start -> Programs -> AppServ -> MySQL Command Line Client Enter Password, then you’ll be working.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
Objectives Connect to MySQL from PHP
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
PHP : Working with Resultsets. Last class  Open a connection to the MySQL server.  Specify the database  Issue queries (no updates at this stage) 
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
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.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Class 3 MySQL Robert Mudge Reference:
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.
Slide 8-1 CHAPTER 8 Using Databases with PHP Scripts: Using MySQL Database with PHP.
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:
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
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)
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Multifarious Project Team Members Alberto Dominguez Nirmit Gang Jimmy Garcia Javier Handal.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
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.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
PHP MySQL. SQL: Tables CREATE TABLE tablename { fieldname type(length) extra info,... } Extra info: –NULL (allows nulls in this field) –Not NULL (null.
Advanced PHP: Using PHP with MySQL C. Daniel Chase The University of Tennessee at Chattanooga.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
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.
Database and mySQL Week 07 Dynamic Web TCNJ Jean Chu.
Lecture 10 – MYSQL and PHP (Part 2)
Welcome to the Web! Session By: Infero - Programming Club, IIT Hyderabad.
Technology & Management Club Development Software Overview.
PHP with MySQL 1.
MySQL Database Connection
Chapter 5 MYSQL Database. Introduction to MYSQL MySQL is the world's most popular open-source database. Open source means that the source code, the programming.
Chapter 8 Databases.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
What’s a database? Data stored in a structured format that lends itself to easy manipulation and recall.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
NMED 3850 A Advanced Online Design January 14, 2010 V. Mahadevan.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
CHAPTER 10 PHP MySQL Database
PHP MySQL1 PHP and MySQL After this lecture, you should be able to:  Access a MySQL database with PHP  mysql_connect()  mysql_select_db()  mysql_query()
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
The Web Wizard’s Guide to PHP by David Lash
Databases.
Ch. 3. MySQL (이 강의의 대부분 예는 tutorialspoint. com/mysql/index
Open Source Server Side Scripting Permissions & Users
Unix System Administration
Session 4 PHP & MySQL.
Introduction to Web programming
Unit 2 MY SQL DATABASE PROGRAMMING
PHP and MySQL.
Chapter 8 Working with Databases and MySQL
Create New User in Database. First Connect the System.
Web Programming– UFCFB Lecture
MySQL Database System Installation Overview SQL summary
Introduction to Web programming
Presentation transcript:

MySQL PHP Web Technology

Logging in to Command Line Start -> Programs -> AppServ -> MySQL Command Line Client Enter Password, then you’ll be working as root.

Browsing Databases Some useful commands to begin with –status; –show databases; - show all databases –use ; –show tables; –desc –create database Create a new database CREATE DATABASE webtech

Create a User It is a good idea to create a username to manage tables in new created database Proper privileges can be granted to a particular user so that only a user who has right access can manage the table GRANT [(col1, col2, … colN)] ON database.[table] TO IDENTIFIED BY 'passwd'; GRANT select ON webtech.tct_phone TO IDENTIFIED BY ‘tct';

MySQL Privilege Scope

Create a Table CREATE TABLE tct_phone ( STD_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, STD_FNAME VARCHAR( 64 ) NOT NULL, STD_LNAME VARCHAR( 64 ) NOT NULL, STD_PHONE VARCHAR( 12 ) NOT NULL ); CREATE TABLE ( column_name1 ….., )

SELECT Statements Select all records (rows) from a table Select some columns of all records from a table SELECT * FROM ; SELECT col1, col2,….colx FROM ; SELECT * FROM tct_phone; SELECT std_id, std_fname, std_lname FROM tct_phone;

SELECT Statements (cont.) Select some records from a table WHERE clause could be any boolean expression ORDER BY clause (either asc or desc) SELECT * FROM tct_phone WHERE std_id > 20; SELECT * FROM WHERE ; SELECT * FROM tct_phone WHERE std_id > 20 and std_fname like ‘sor%’; SELECT * FROM tct_phone WHERE std_id > 20 and std_fname like ‘sor%’ ORDER BY std_fname desc;

Connecting to Database Using PHP $hostname = “localhost”; $dbUser = “tct”; $dbPass = “tct”; $conn = mysql_connect($hostname, $db_user, $password) or die(“Cannot open connection”); mysql_connect(HOSTNAME, USER, PASSWD);

Selecting a Database mysql_select_db(“webtech”, $conn ) or die ("Cannot open database") ; mysql_select_db(DATABASE, CONNECTION);

Making Query Making query to opened database Checking the number of fields from the query Checking the number of records we get mysql_query($query); mysql_num_fields($result) mysql_affected_rows()

How to Retrieve the Records There are a number of ways to get them: $name_row = mysql_fetch_row($result) $row = mysql_fetch_object($result) $row = mysql_fetch_array($result) while ($name_row = mysql_fetch_row($result)) print("$name_row[0] $name_row[1] $name_row[2] \n"); while ($row = mysql_fetch_object($result)) print("$row->std_id -> $row->std_fname $row->std_lname \n"); while ($row = mysql_fetch_array($result)) print($row[std_id '].$row[std_fname '].$row[std_lname'] \n");

Example Code $conn = mysql_connect(‘localhost’, ‘tct’, ‘tct’) or die("Cannot open connection"); mysql_select_db(“webtech”, $conn ) or die ("Cannot open database"); mysql_db_query("tct_phone","SET NAMES utf8");//Use UTF8 for Thai font $query = "select * from tct_phone"; $result = mysql_query($query); $num_fields = mysql_num_fields($result); echo " "; for($i=0; $i ".mysql_field_name($result, $i)." "; echo " "; while ($name_row = mysql_fetch_row($result)) { echo " "; for($i=0; $i $name_row[$i] "); echo " "; } echo " ";