DOC PREVIEW
K-State CIS 764 - Study Guide

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

AN APPLICATION IN PHP WITH ORACLE DATABASE AS BACKEND AND DEPLOYED ON APACHE WEBSERVER CHAITANYA R MITTAPELLI [email protected] CIS 764, CIS, KSU Fall 2006 Purpose: To develop a small application in PHP with connection to a oracle database. Overview: Here we develop a small application called as Library Information System. It connects to the oracle database to retrieve the information about the books. Prerequisites; Before starting the tutorial, you should: 1. Have access to or have installed Oracle Database 10g (Release 2 or Release 1). One can download it from Oracle Technology Network (http://www.oracle.com/technology/software/products/database/oracle10g/index.html). 2. PHP 4.3.4 or later. http://www.php.net/downloads.php 3. A web server such as Apache 1.3 or later. http://httpd.apache.org/download.cgiThe following steps have to be performed: 1.Creating the tables. The following tables have to be created. Table Book with columns BOOKID,TITLE,AUTHOR,TOTALCOPIES,AVAILABLE. BOOKID is the primary key. 2. Writing the PHP code. A connection has to be established to the database. This is done with below given code. if ($c=OCILogon("chaitu", "cis764", "oracle.cis.ksu.edu")) echo "Successfully connected to Oracle.\n"; else { $err = OCIError(); echo "Oracle Connect Error " . $err[text]; }Now we need to execute a select query from the PHP source Code. It is done by the following code. $s = OCIParse($c, "SELECT * FROM Book where TITLE='".$name."'"); OCIExecute($s, OCI_DEFAULT);Now we need print the retrived rows with required formatting.It can be done with while (OCIFetch($s)) { echo "<tr><td align=center>"; echo ociresult($s, "TITLE") .; echo "</td><td align=center>"; echo ociresult($s, "AUTHOR") .; echo "</td><td align=center>"; echo ociresult($s, "TOTALCOPIES") .; echo "</td><td align=center>"; echo ociresult($s, "AVAILABLE") .;In this way we build the required application. This Library Information System helps in searching the books. The home page looks as shown below.Now we can search for a book either by book title or by author. Let’s select by book title. The page opens up and lets search for SOFTWARE ENGINERINGClick submit and then we see the following pageWe can also search by Author as Shown belowThe search results are displayed as shown below.Thus we have successfully connected to the Oracle database from the PHP code and we have retrieved the required


View Full Document

K-State CIS 764 - Study Guide

Documents in this Course
Load more
Download Study Guide
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Guide and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Guide 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?