Website Development & Management PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT 3353 -- Fall 2006 www.clt.astate.edu/jseydel/mis3353.

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

Java Script Session1 INTRODUCTION.
Lesson 4 Advanced Forms Handling. Aggravations Long forms that make you scroll out of the normal viewing area Lets create a scrollable form that is a.
PHP (2) – Functions, Arrays, Databases, and sessions.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
Website Development & Management More PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic PHP.
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
Objectives Connect to MySQL from PHP
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.
Website Development Working with MySQL. What you will achieve today! Connecting to mySql Creating tables in mySql Saving data on a server using mySql.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
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 &
Website Development & Management Getting to Know HTML Better CIT Fall Instructor: John Seydel, Ph.D.
INTERNET APPLICATION DEVELOPMENT For More visit:
Website Development & Management More PHP Fundamentals CIT Fall Instructor: John Seydel, Ph.D.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
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.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
PHP meets MySQL.
Website Development & Management Getting Started with Databases Instructor: John Seydel, Ph.D. CIT Fall
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
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.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
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.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Website Development & Management Going Live with Web Pages (b) CIT Fall Instructor: John Seydel, Ph.D.
Concepts of Database Management Seventh Edition
HTML, PHP, and MySQL: Putting It All Together. Making a Form Input tags Types: “text” “radio” “checkboxes” “submit”
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Electronic Commerce Server-Side Scripting Exercises MIS Spring 2006 Instructor: John Seydel, Ph.D.
PHP Database Processing CIS 1715 Web Technologies.
Website Development & Management Going Live with Web Pages (a) CIT Fall Instructor: John Seydel, Ph.D.
Website Development & Management A PHP Exercise CIT Fall Instructor: John Seydel, Ph.D.
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)
PHP and SQL Server: Queries IST2101. Steps to Design PHP Pages to Answer User Queries 1.Query generation – What SQL query do we need to retrieve the desired.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
CSC 405: Web Application Engineering II8.1 Web programming using PHP What have we learnt? What have we learnt? Underlying technologies of database supported.
Website Development & Management Some Wrap-Up Items Instructor: John Seydel, Ph.D. CIT Fall
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,
Form Data (part 2) MIS 3502, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015 Slide 1.
Setting up a Development Environment. What you need Webserver (Apache) Database (MySQL) PHP All in Uniserver (google “uniserver”) Download the windows.
PHP Overview. What is PHP Widely available scripting language Free Alternative to Microsoft’s ASP Runs on the Web Server; not in the browser Example:
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
Introduction to Dynamic Web Programming
Web Database Programming Using PHP
Web DB Programming: PHP
Tutorial 6 PHP & MySQL Li Xu
Presentation transcript:

Website Development & Management PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall

Student Objectives Upon completion of this class meeting, you should be able to: Summarize the steps involved in using PHP to accomplish basic database queries Use PHP to display database contents to a web page Create an onLoad event handler for a web page

Using PHP to Interface with MySQL Always starts with the creation of a connection Requires opening a database Generally involves generating a recordset (aka, result set) Processing the recordset typically involves some sort of looping construct One repetition per record Must be controlled by some sort of counter: foreach(), while(), and for() Makes use of several important functions...

PHP Functions for Basic Queries Create a connection: mysql_connect() Arguments (string): server, userID, password Returns a string (connection information) Open a database: mysql_select_db() Arguments (string): database to be used, connection Returns a boolean value Create a recordset: mysql_query() Arguments (string): SQL query, connection Returns a recordset (an array of data) Process a recordset: mysql_num_rows()  Argument (array): recordset  Returns an integer (number of records) mysql_fetch_array()  Arguments (string): recordset  Returns a row from the recordset

Let’s Complete the First Database Exercise Where we left off: Initial values assigned Connection created Database opened Recordset created Note: three line equivalent (poor coding) What’s left: Process the records (a row at a time)  Get data for each row in the database table  Assign those data to variables  Add to the output block Incorporate output block into the HTML section

A Bit More on QueriesQueries Not just getting information from a database Also involves putting information into a database Creating databases Creating tables Adding records to tables Modifying (updating) existing records Require the use of SQL (structured query language), a universal database language Reference material: so far, mostly the class notes

Summary: What We’ve Seen Recently New PHP functions mysql_connect() mysql_select_db() mysql_query() mysql_num_rows() mysql_fetch_array() A little SQL Used directly with MySQL Incorporated into PHP script The for() construct How to use PHP to connect to MySQL, open a database, create a recordset, and process that recordset How/where MySQL files are storedstored

The FKAuto Database Files For use on your own computer: Download these Available in the Documents directory (not public_html) of the cit3353 account on SuSE1  Recall the password?  All three files for the UsedCars database are in a directory named fkauto For use on SuSE1: don’t worry about where they are, as they are available to your scripts However, the “owner” is user cit3353 Thus use the appropriate values for user and password

Some Other Things: FKAuto Calculator Page (calc.php) JavaScript: used within the onLoad event handler for the element Note the arrays Use of the range() function Alternatively, but more work: array() foreach() construct

Appendix

How MySQL Stores the Data Each table (i.e., relation) involves three files: TableName.frm TableName.MYD (where the actual data are) TableName.MYI The files for all the tables belonging to a given database are stored in a directory with the same name as the database All database directories are stored in the data directory within c:\mysql

Working with MySQL Get started mysql -u jojobeans –p USE testDB; SHOW TABLES; Using tables CREATE TABLE tblTest (testID int, testNote text); EXPLAIN tblTest; SELECT * FROM tblTest; INSERT INTO tblTest VALUES (123,’First entry’); INSERT INTO tblTest VALUES (456,’Second entry’); SELECT * FROM tblTest; QUIT;