Database-driven Web Pages from Access Databases Stephen Rondeau TINST312 18 May 2009.

Slides:



Advertisements
Similar presentations
Publication Module using back end interface. Institution Data Entry Add Documents. Edit/Delete Documents that are added but not yet sent to Institution.
Advertisements

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Keys, Referential Integrity and PHP One to Many on the Web.
Murach’s Java SE 6, C21© 2007, Mike Murach & Associates, Inc.Slide 1.
Web Database Programming Connecting Database to Web.
Data-Driven Web Pages Stephen Rondeau 18 May 2009.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
4/8/99 C. Edward Chow Page 1 Internet Services Manager Click Start | Programs | Administrative Tools | Internet Services Manager.
U:/msu/course/cse/103 Day 23, Slide 1 Review of Day 22 What query did you use to search for an actor by name? –Return matches.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
ADVM420- Class #4 Web Design with PHP and MySQL Adding and Listing from a MySQL Database.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
PHP Programming. Topics Background and History of PHP Installation Comments in PHP Variables Conditions Loops Functions File Handling Database Handling.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
U:/msu/course/cse/103 Day 25, Slide 1 Back-up PHP Files If you have not yet passed the 3.0 BT, make back-up copies of ALL.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
© 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.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
PHP meets MySQL.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
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.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Hello We are looking for a coder to code the following We have a network that has different sites: we need an application that will scan the network and.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
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.
Creating PHPs to Insert, Update, and Delete Data CS 320.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
DT228/3 Web Development Databases. Querying a database: Partial info Search engines, on-line catalogues often need to allow user to search a database.
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.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
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.
U:/msu/course/cse/103 Day 21, Slide 1 CSE 103 Makeups –If you didn’t take one over the weekend, take one TUESDAY or WEDNESDAY!
PHP Programming. Topics Database Handling (MySQL, MSSQL, ODBC)
Database to HTML and Back again A programmers tale.
SQL Server Microsoft SQL Server 6.5 (startup menu) We’ll use two facilities –Enterprise Manager: to build your db –ISQL_w: to run queries Use this for.
OBJECTIVES Learn how to view data using SQL and PHP Learn how to add new data using SQL and PHP PHP+SQL: View and Adding,
به نام خدا SQL QUIZ جوانمرد Website: ejavanmard.blogfa.com.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Introduction to Dynamic Web Programming
Database application MySQL Database and PhpMyAdmin
22-INTEGRATION HUB
Website Development Basics with PHP MySQL
PHP Overview PHP: Hypertext Preprocessor Server-Side Scripting
ISC440: Web Programming 2 Server-side Scripting PHP 3
Web Systems Development (CSC-215)
Developing a Model-View-Controller Component for Joomla Part 3
Grauer and Barber Series Microsoft Access Chapter One
Database Connections.
Updating Databases With Open SQL
Introduction to Web programming
Updating Databases With Open SQL
Presentation transcript:

Database-driven Web Pages from Access Databases Stephen Rondeau TINST May 2009

Agenda Converting Access DB to SQL Server Connecting to Database Displaying a Table Searching a Table Adding/Changing/Deleting Table Contents

References Documentation (includes PHP source) – Web Page Examples – / /

Prereqs It will help a lot if you know: –HTML (br, tables, form, input) –SQL statements (select, insert, update, delete) –a programming language variable assignments function calls and returns if-then-else while loop working with strings

Conversion of Access to SQL Server Have system admin install and configure SQL Server and add a user id and password for you Setup ODBC connection to SQL Server –via Control Panel/Administrative Tools/ODBC Administrator Select table to export –Right-click on it and choose "Export…" –In "Save as type", choose "ODBC Databases" –Find ODBC definition –Save it there

Connecting to Database Have system admin install and configure PHP ODBC Save as file "connect_db.php": <?php $db = odbc_connect("dsn", "user", "pw") or die "not connected"; print "connected "; ?> – –dsn is reference to database or "data set name" –user is database user id; pw is password for that user id

Displaying a Table Copy "connect_db.php" to "show.php" In place of print line: $stmt = "select * from tblEmployees"; $result = odbc_exec($db, $stmt); if ($result == FALSE) die("Problem with $stmt"); while (odbc_fetch_row($result)) { print odbc_result($result, "LastName"). ", ". odbc_result($result, "FirstName"); print " "; } –

Searching a Table Two part process: –Part 1: accept search "key" from the user –Part 2: perform the search using the key Part 1: Asking the user is HTML; save as "get_key.php" Last Name:

Searching a Table, Part 2 Part 2: performing the search is PHP; copy "show.php" to "search.php" and modify as follows $key = str_replace("'", "''", $_POST["key"]); $stmt = "select * from tblEmployees where LastName = '$key'"; –First line gets key passed from "get_key.php", replacing each single quote with two single quotes –Second line uses SQL to search table for matching last name

Adding/Changing/Deleting Table Contents Standard form (table display): Add a record Change/Delete record 1… Change/Delete record 2… Change/Delete record 3… etc. "Add a record" is a link to add.php, which asks user for field values of record "Change" is a link to change.php with the record id supplied "Delete" is a link to del.php with the record id supplied

HTML for Add/Change/Delete HTML: Add a record Change / Delete … add.php doesn't require an id: new record change.php and del.php pass the id value in the query string; here the id is 24, e.g.

Add Process Like searching, two parts: –Part 1: get values from user for fields of record –Part 2: insert the record in the table with id add.php: Last Name: First Name:

Add Process, Part 2 add_rec.php (just the important pieces): $lastname = str_replace("'","''",$_POST["lastname"]); $firstname = str_replace("'","''",$_POST["firstname"]); $stmt = "select max(employeenumber)+1 from tblEmployees"; $result = odbc_exec($db, $stmt); $new_id = odbc_result($result, 1); $stmt = "insert into tblEmployees(employeenumber, lastname, firstname) values($new_id, '$lastname', '$firstname')"; $result = odbc_exec($db, $stmt); if ($result == FALSE) die("Could not insert $stmt");

Change Process Three parts: –Part 1: get values from table –Part 2: let user change field values of record –Part 3: update the record using id and other values

Change Process, Part 1 change.php (first part): <?php include 'connect_db.php'; $id = $_GET["id"]; $stmt = "select * from tblEmployees where employeenumber=$id"; $result = odbc_exec($db, $stmt); if ($result == FALSE) die("Could not find $id: $stmt"); $lastname = odbc_result($result, "LastName"); $firstname = odbc_result($result, "FirstName"); odbc_close($db); ?>

Change Process, Part 2 change.php (second part): <input type="hidden" name="id" value=" "> Last Name: <input type="text" name="lastname" value=" "> First Name: <input type="text" name="firstname" value=" ">

Change Process, Part 3 change_rec.php (just the important pieces): $id = $_POST["id"]; $lastname = str_replace("'", "''", $_POST["lastname"]); $firstname = str_replace("'", "''", $_POST["firstname"]); $stmt = "update tblEmployees set lastname='$lastname', firstname='$firstname' where employeenumber=$id"; $result = odbc_exec($db, $stmt); if ($result == FALSE) die("Could not update: $stmt");

Delete Process Could be simple – delete immediately via del.php (just the important pieces): $id = $_GET["id"]; $stmt = "delete from tblEmployees where employeenumber=$id"; $result = odbc_exec($db, $stmt); But deleting immediately doesn't allow for user mistake – should confirm with the user search for info associated with id (e.g., lastname and firstname) display info to user and ask for permission to delete, then delete as above if okay how to do the confirmation is left as an exercise for the reader