SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section 1 09-21-04 PHP and MySQL.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

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.
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
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.
Objectives Connect to MySQL from PHP
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
WHAT IS PHP PHP is an HTML-embedded scripting language primarily used for dynamic Web applications.
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
Programming with php By: Seth Larson. A little bit about PHP  PHP stands for PHP:  Hypertext Preprocessor  PHP is a widely-used general-purpose server-side.
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.
Databases with PHP A quick introduction. Y’all know SQL and Databases  You put data in  You get data out  You can do processing on it very easily 
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
Mandakini Ayushi Infotech Mandakini Kumari 22 nd July PHP Basic.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
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.
Nael Alian Introduction to PHP
Multifarious Project Team Members Alberto Dominguez Nirmit Gang Jimmy Garcia Javier Handal.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
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.
Lecture 10 – MYSQL and PHP (Part 2)
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Creating PHPs to Insert, Update, and Delete Data CS 320.
Introduction to PHP Advanced Database System Lab no.1.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik last time updated in 2012.
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.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
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.
Accessing mySQL relational database. MySQL database.  Today, we will attempt and open a connection to the MySQL server.  We need to specify the database.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
PHP Introduction PHP is a server-side scripting language.
CHAPTER 10 PHP MySQL Database
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
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,
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
SQL Injection By Wenonah Abadilla. Topics What is SQL What is SQL Injection Damn Vulnerable Web App SQLI Demo Prepared Statements.
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 8 – Review Reference:
PHP stands for …….. “PHP Hypertext Pre-processor” and is a server-side scripting language like ASP. PHP scripts are executed on the server PHP supports.
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
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.
1 Server Side scripting PHP. 2 What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are.
PHP using MySQL Database for Web Development (part II)
Introduction to Dynamic Web Programming
Web Design and Development
Computer Security Fundamentals
PHP / MySQL Introduction
PHP Introduction.
ISC440: Web Programming 2 Server-side Scripting PHP 3
Tutorial 6 PHP & MySQL Li Xu
MySQL Web Application Connecting to a MySQL database
Presentation transcript:

SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section PHP and MySQL

SJSU CS157B Dr. Lee2  2004 Jenny Mitchell We are learning about databases, now what can we do with that knowledge? Oracle –Large download and installation –Most of us used Oracle 9 in 157A MySQL –Small download or use from web server –Same SQL syntax, run from command line or other application Putting Our Knowledge to Use

SJSU CS157B Dr. Lee3  2004 Jenny Mitchell GNU Free, open-source, multi-platform Implements the standard SQL language Relational DBMS Written in C and C++ Uses MyISAM B-tree disk tables Uses in-memory hash tables for temporary tables About MySQL

SJSU CS157B Dr. Lee4  2004 Jenny Mitchell Developer Zone: Downloads and Documentation Available for Linux, Windows, Solaris, FreeBSD, and more MySQL.com

SJSU CS157B Dr. Lee5  2004 Jenny Mitchell Download 4.0 binary packages Check installation documents to see what is automatically installed where Add appropriate aliases and users First start up in safe mode and test default tables Run from shell or application MySQL Installation

SJSU CS157B Dr. Lee6  2004 Jenny Mitchell MySQL Terminal Example

SJSU CS157B Dr. Lee7  2004 Jenny Mitchell In-Class Demo Insertion MySQL Terminal Example

SJSU CS157B Dr. Lee8  2004 Jenny Mitchell What languages can we use for building an application on MySQL? –ODBC Connector –JDBC Connector –.NET Connector –Web scripting languages PHP, ASP, JSP Building On MySQL

SJSU CS157B Dr. Lee9  2004 Jenny Mitchell PHP: Hypertext Processor Open source scripting language for web developers to write dynamically generated webpages Can download and install source and binaries from Need your computer to act as a server –Apache, Tomcat are free downloads PHP

SJSU CS157B Dr. Lee10  2004 Jenny Mitchell Syntax similar to C and JavaScript Not a compiled language, interpreted –You don’t know where an error is until you try to run it, and even then the line number doesn’t always tell you where the actual error is Same logical structure - if/else, for, while Variables have no type declaration Basic PHP Scripting

SJSU CS157B Dr. Lee11  2004 Jenny Mitchell <?php $world = true; if ($world) echo(“Hello World!”); else echo(“Hello Nobody”); ?> Hello, World!

SJSU CS157B Dr. Lee12  2004 Jenny Mitchell <?php $world = false; if ($world) echo(“Hello World!”); else echo(“Hello Nobody”); ?> Hello Nobody

SJSU CS157B Dr. Lee13  2004 Jenny Mitchell Anything in a MySQL database can be viewed on a webpage Any information which can be captured from a website can be stored into a database FORMS Uses of PHP and MySQL

SJSU CS157B Dr. Lee14  2004 Jenny Mitchell /* Connection */ $username = ‘user’;// username $password = ’password'; // password $webhost = 'localhost';// host (localhost or something on a web server) $db = ’test';// the database $dbc = mysql_connect($webhost, $username, $password) or die(" Could not connect: ". or die(" Could not find database - $db - ". mysql_error(). " "); Connecting to MySQL from PHP

SJSU CS157B Dr. Lee15  2004 Jenny Mitchell /* Perform SQL query and catch data */ $query = "SELECT * from t1 WHERE != ‘’ ORDER BY name ASC"; $result = mysql_query($query) or die(" Query failed: ". mysql_error(). " "); Queries and Results

SJSU CS157B Dr. Lee16  2004 Jenny Mitchell $num = echo “ ”; echo " ID Name "; for ($i = 0; $i < $num; $i++) { $line = mysql_fetch_array($result); echo " "; echo " ". $line[id]. " "; echo " ". $line[name]. " "; echo " ". $line[ ]. " "; echo " "; } echo " "; /* Housekeeping */ mysql_free_result($result); mysql_close($dbc); Displaying Results

SJSU CS157B Dr. Lee17  2004 Jenny Mitchell SQL Query statements can be built over time PHP variables can be used in SQL Query statements Variables can be generated based on input form values Selection and Variables

SJSU CS157B Dr. Lee18  2004 Jenny Mitchell HTML FORM CODE Enter a column name by which to sort: SQL PROCESSING CODE /* Gather data from form variable */ $column = $_POST['column']; /* Perform SQL query to catch data */ $query = "SELECT * from t1 WHERE != '' ORDER BY $column ASC"; $result = mysql_query($query) or die(" Query failed: ". mysql_error(). " "); Selection and Variables Code

SJSU CS157B Dr. Lee19  2004 Jenny Mitchell In-Class Demo Data Mining from Forms Selection and Variables

SJSU CS157B Dr. Lee20  2004 Jenny Mitchell Create form with all input variables you want, submit action to someform.php PHP script grabs all “post”ed variables in the form $var = $_POST[‘var’]; Note that empty variables are the empty string and not the null value Insertion with Forms

SJSU CS157B Dr. Lee21  2004 Jenny Mitchell HTML FORM CODE Insert some data into this database Name: SQL PROCESSING CODE /* Gather data from form variable */ $name = $_POST['name']; $ = $_POST[' ']; /* Perform SQL query to catch data */ $query = "INSERT INTO t1(name, ) values(\"$name\", \"$ \")"; mysql_query($query) or die(" Query failed: ". mysql_error(). " "); $num = mysql_affected_rows(); if ($num == '1') echo " Data was inserted successfully"; Insertion with Forms Code

SJSU CS157B Dr. Lee22  2004 Jenny Mitchell In-Class Demo Inserting Data Insertion with Forms

SJSU CS157B Dr. Lee23  2004 Jenny Mitchell MySQL - relational database package which is free, small, easy to install PHP - dynamic scripting language which is free, small, easy to install, and automatically works with MySQL MySQL + PHP = affordable, portable, easily accessible database backend & application frontend In Conclusion…

SJSU CS157B Dr. Lee24  2004 Jenny Mitchell What Are You Waiting For? GO BUILD!