<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<!--
    SECOND example connecting to Oracle!

    uses: hum_conn_no_login.php

    by: Sharon Tuttle
    last modified: 2026-04-01

    you can run this using the URL:
https://nrs-projects.humboldt.edu/~st10/s26cs328/328lect10-2/328lect10-2.php
-->

<head>
    <title> Oracle Demo 2 </title>
    <meta charset="utf-8" />

    <?php
        ini_set('display_errors', 1);
        error_reporting(E_ALL);

        /* get the function hum_conn_no_login */

        require_once("hum_conn_no_login.php");
    ?>
    
    <link href="https://nrs-projects.humboldt.edu/~st10/styles/normalize.css"
          type="text/css" rel="stylesheet" />
</head>

<body>

    <h1> Our Second Connection from PHP to Oracle! </h1>
    
    <?php
    // use hum_conn_no_login function to hide the connection details

    $conn = hum_conn_no_login();

    /*===
        IF reach here, connection succeeded!
    ===*/
    ?>

    <p> YAY!!!!!!! we connected! </p>

    <?php
    /*=== query employee names, hiredates, and salaries ===*/

    $empl_query = "select empl_last_name, hiredate, salary
                   from empl
                   order by empl_last_name";

    $empl_stmt = oci_parse($conn, $empl_query);

    oci_execute($empl_stmt, OCI_DEFAULT);
    ?>

    <!-- start a paragraph of employee information -->
    
    <p>
    
    <?php
    // this query may return MULTIPLE rows, SO...
	
    while ( oci_fetch($empl_stmt) )
    {
        // demoing both types of 2nd argument options for oci_result
	
        ?>
	
        <?= oci_result($empl_stmt, "EMPL_LAST_NAME") ?>,
	<?= oci_result($empl_stmt, 2) ?>,
	<?= oci_result($empl_stmt, "SALARY") ?> <br />
	
	<?php
    }
    ?>

    <!-- now complete the paragraph element -->
    
    </p>
    
    <?php
    // free my statement, close my connection

    oci_free_statement($empl_stmt);
    oci_close($conn);
    ?>
    
    <footer>
    <hr />
    <p>
        Validate by pasting .xhtml copy's URL into<br />
	<a href="https://validator.w3.org/nu">
            https://validator.w3.org/nu
        </a>
	or  
        <a href="https://html5.validator.nu/">
            https://html5.validator.nu/
        </a>
    </p>
    </footer>
</body>
</html>