Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 









Oracle Database Tips by Donald Burleson



The next script, abundantly used throughout the tool, defines the function "csr2html", used to present a relational cursor as an HTML table.  Here is the content of the csr2html.php script: 

require_once "HTML/Table.php";
function csr2html(&$sth,$fill="n/a") {
   GLOBAL $rattrib;
   for($i=0; $i<= $ncols;$i++) {
   $tableAttrs = array("rules"  => "rows,cols",
                       "border" => "3",
                       "align"  => "center" );
   $hattr=array("style" => "background-color: #ADD8E6");
   $table = new HTML_Table($tableAttrs);
   $table -> setAutoGrow(true);
   $table -> setAutoFill($fill);
   for($i=0;$i<$ncols;$i++) {
   while ($row=$sth->fetchRow()
) {

This is the same example shown in Chapter 4 with very few changes. The only change is the global array $rattrib, added later in the coding phase to allow me to align table values differently in different scripts.  It was not created as an argument to the function because of simplicity.  This was the simplest solution. This function is used in every menu item throughout the tool. The login form is the same as in Chapters 3 and 4 with a bit more elaborate look:


<?php function login_form($init_usr) { ?>
<h2>DBA Helper</h2>
You are running for the shelter of DBA's little helper
It will help you on your way, get you through your busy day
<form action=<?=$_SERVER['PHP_SELF']?> method="post">
   cellspacing="0" border="2"
<th align="center">
<td colspan="2" align="center">Login:</td>
 <td><input type="text"
      value= <?php
          if (!empty($_POST['user']))
               echo $_POST['user'];
               else  echo "$init_usr";
<td><input type="password" name="passwd" size="20"></td>
<td><input type="text" name="database"  size="20"
<td><input type="submit" name="login" value="login"></td>
<?php } ?>

The only difference from the login form used throughout this book is the fact that this form is placed within a table, giving it a distinctive look. The same applies to the main menu. The procedure dba_helper.php does the same thing as Example 13 and its modifications; it checks the database login, starts the session and stores the connection parameters as session variables. When everything is checked, it uses the "header" function to display the following HTML file, appropriately named "frames.html":


<title>DBA Helper Main Menu</title>
<frameset cols="20%,80%">
<frame name="menu" src="main_menu.html">
<frame name="output" src="init.php">
    Sorry, this tool can not be used if your browser<br>
    does not support frames

This creates the frames and invokes the initial screen, showing the main menu and the output of the script "init.php". The next interesting script is "init.php". It is a very small script, but with some interesting elements:

<body bgcolor="#EFECC7">
$db = NewADOConnection("oci8");
$VER='select * from v$version';
$TIM="select to_char(startup_time,'MM/DD/YYYY HH24:MI:SS')
      from v\$instance";
try {
    echo "<h4>Connected to
    echo "<pre>\n";
    while($row=$rs1->FetchRow()) {
        echo "\t".$row[0]."\n";
        if (preg_match($pat,$row[0],$match)) {
catch (Exception $e) {

This script displays the database name and version, and stores the major version of the database and the date that the instance was started as session variables. The interesting part is the use of the preg_match PHP function which performs a Perl regular expression match. The syntax of the function is shown as follows:


This searches the string, $string for a pattern, $pattern and puts the resulting matches in the array, $matches. The preg_match function stops searching the array as soon as the first match is encountered. If we need to search the entire string $string, the preg_match_all function is used instead of preg_match. Our pattern was defined by the expression $pat='/^CORE\s+([0-9]+)/'; which means this:

"The string that begins with CORE followed by one or more space characters which are, in turn, followed by one or more digits".  Digits are remembered as $match[1] because of the parenthesis around the expression for "one or more digits", "[0-9]+". Regular expressions are quite complicated topic in itself and is even a subject of a separate book.  The classic reference for everything about the regular expressions is found in the book by Jeffrey Friedl, "Mastering Regular Expression", published by O'Reilly Publishers.

The short introduction to the Perl variety of regular expressions, also used by PHP, is the llama book, "Learning Perl" by Randal Schwartz and Tom Christiansen. It was also published by O'Reilly Publishers and has a llama on the cover page. Perl regular expressions are implemented in PHP by using the PCRE library (Perl Compatible Regular Expressions) which is used by many software products, so learning how to use Perl regular expressions makes a lot of sense and is not a wasted effort.

On-line information is also available at well known web sites, such as and The init.php file outputs the initial page seen earlier in this chapter.

Also worth noticing is the structure of the file. The file begins with <html> and <body> tags, and the background color is set in the <body> tag. This is the simplest way to set the background color and all scripts comprising DBA_Helper use this method for setting the background colors.

See code depot for complete scripts

This is an excerpt from the book Easy Oracle PHP.  You can get it for more than 30% by buying it directly from the publisher and get instant HTML-DB scripts from the code depot:

Easy Oracle PHP
Create Dynamic Web Pages with Oracle Data

Includes online HTML-DB code depot

Buy it now for 30% off - Only $19.95

HTML-DB support:

For HTML-DB development support just call to gat an Oracle Certified professional for all HTML-DB development projects.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.