2

I've a PHP script to fetch the data from Oracle SQL. I need to include fetch statement in HTML code. Basically I want to process all PHP related and database related queries in PHP tag and wherever required, i can fetch the result from the array rather again include oci_fetch() and oci_result statements.

e..g,

<?php
/* Database Connection*/

if(!$dbConn = oci_connect('WHSUSR','goldeneyex','MyServer.biz:1530/OSLTP')){
    $err = oci_error();
    trigger_error('Could not establish a connection: ' . $err['message'], E_USER_ERROR);
};

/* Query to get Users last accessed appication */
$strSQLUserLogInDetails = "select v.user_name,  max(start_time) from sessiont s inner join V_BO_USER_CODES v on v.user_obj_id = s.user_id
                                    where v.user_name not in ('KALIDO MDM Anonymous User', 'KALIDO MDM Publication Service User')
                            group by v.user_name
                            order by 2 desc";

$stmtUserLogInDetails = oci_parse($dbConn,$strSQLUserLogInDetails);
if ( ! oci_execute($stmtUserLogInDetails) ){
    $err = oci_error($stmtUserLogInDetails);
    trigger_error('Query failed: ' . $err['message'], E_USER_ERROR);
};
?>

and HTML code below...

<table class="table table-striped" title="List of Users who last accessed Kalido application">
    <thead><tr><th>User Name</th><th>Last Accessed On</th></tr></thead>
    <tbody>                     
        <?php
            while(oci_fetch($stmtUserLogInDetails)){
                $uname = oci_result($stmtUserLogInDetails, 1);
                $datetime = oci_result($stmtUserLogInDetails, 2);
                print "<tr><td><a href='userlevelreport.php?uname=".$uname."'>" .$uname. "</a></td><td>".$datetime."</td></tr>";
            }
        ?>
    </tbody>
</table>
1
  • Just so you know, to format text as Code you just need to select the text and press the {} button Commented May 24, 2013 at 15:45

2 Answers 2

1

Use the function oci-fetch-array.

On that link you have some examples how to use it.

In your particular case:

...

$rows = array();
if ( ! oci_execute($stmtUserLogInDetails) ){
    $err = oci_error($stmtUserLogInDetails);
    trigger_error('Query failed: ' . $err['message'], E_USER_ERROR);
}
else
{
    while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
        $rows[] = $row; 
    }
}

$rows will contain an array with your results.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use this function:

oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.