PHP and SQL Server: Connection IST 210: Organization of Data IST2101.

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

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Keys, Referential Integrity and PHP One to Many on the Web.
Web Database Programming Connecting Database to Web.
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen automatically using rand() function.
PHP (2) – Functions, Arrays, Databases, and sessions.
Multiple Tiers in Action
Apache Tomcat Server Typical html Request/Response cycle
Website Development & Management PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
PHP and SQL Server: Queries IST2101. Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102.
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.
1 Working with MS SQL Server II. 2 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom.
SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section PHP and MySQL.
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,
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
Homework for October 2011 Nikolay Kostov Telerik Corporation
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
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.
© 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.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
HTML Table and PHP Array
Web-Based Database Programming with PHP. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn PHP Basics PHP functions –To.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen randomly using rand() function.
Damian Tamayo Tutorial DTM Data Generator Fall 2008 CIS 764.
Creating PHPs to Insert, Update, and Delete Data CS 320.
PHP Database Processing CIS 1715 Web Technologies.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
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: Connection IST2101. Typical web application interaction (php, jsp…) database drivers 2IST210.
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.
A Simple Website using Cascading Style Sheets (CSS) IST2101.
Database Access Using JDBC BCIS 3680 Enterprise Programming.
Database Access Control IST2101. Why Implementing User Authentication? Remove a lot of redundancies in duplicate inputs of database information – Your.
Agenda for Class 2/20/2014 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT)
CSC 405: Web Application Engineering II8.1 Web programming using PHP What have we learnt? What have we learnt? Underlying technologies of database supported.
Courses NumNameDesc Record Field Table Credits. “PROJECT”“SELECT” Operators on Tables.
Database to HTML and Back again A programmers tale.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
HTML FORM AND PHP IST 210: Organization of Data IST210 1.
PHP ARRAY AND HTML TABLE IST 210 Organization of Data IST210 1.
PHP AND SQL SERVER: QUERIES IST 210: Organization of Data IST210 1.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP Array and HTML Table IST 210 Organization of Data IST2101.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
DATABASE ACCESS CONTROL IST Question Almost every PHP page needs to interact with database, does that mean sqlUsername and sqlPassword need to be.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
How To Start a SQL server Connecting to SQL Server.
PHP AND SQL SERVER: CONNECTION IST 210: Organization of Data IST210 1.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
PHP Overview PHP: Hypertext Preprocessor Server-Side Scripting
Cookies BIS1523 – Lecture 23.
Database Driven Websites
Web Systems Development (CSC-215)
Lecture 2 - SQL Injection
Presentation transcript:

PHP and SQL Server: Connection IST 210: Organization of Data IST2101

Typical web application interaction (php, jsp…) 2IST210 PHP includes functionality that allows you to work directly with different types of databases

When you query a database… IST2103 Step2. Select the database Step1. Connect to the MS SQL server Server Name: updb1 Authentication: SQL Server Authentication Step3. Input a query and execute it Step4. When you are done, close the application

Let PHP do that … Basic Steps for PHP Database Access 1.Connect to the MS SQL server 2.Perform SQL operations 3.Display results on webpages 1.Get the results and manipulate on the website 4.Disconnect from the server 4IST210

Example IST2105

HTML Form and PHP IST2106 Get the table name from HTML form In PHP, fetch the table name from $_POST

Step 1. Open a DB Connection IST2107 Forgot your password? Go to sqlsrv_connect():

Step 2. Use SQL to Query your DB IST2108 sqlsrv_query()

IST2109 If input table is “project”, the generated query is “SELECT * FROM project” Execute the SQL command “SELECT * FROM project” Same as you execute SQL in Management studio Tip: If your code has bug, it is good to print your query on webpage, and try to run it in the management studio. It could be the way you generate the query is wrong.

Step 3. Display Results on Webpage IST21010 sqlsrv_fetch_array(): sqlsrv_field_metadata():

IST21011 Result in management studio Result shown on webpage (in table) Put the result in the table Fetching all the fields and print the field names The header is the field Fetching each row of the result Fetching each column of that row $row is an array, $cell is an element in the array Refer to previous lectures about array, loop, and table

Step 4. Close a DB connection You should close a DB connection to release resources 12IST210

In-Class Exercise 1.Download the query.php to your webspace on our course webpage 2.Modify the database information 3.Connect web server and database server IST21013

Step 1 IST21014 Webspace Make sure the filename is query.php And the type is “All Files”

Step 2 IST21015 Input your own information Forgot your password? Go to

Step 3 IST21016 Note: you may not have PROJECT table in your database! Check out what tables you have! Go to MS SQL Management Studio  Go to your database (your PSUID)  Go to Tables If you do not have any table in your database, download the scripts in SQL-1 class to create tables Visit