oracle select with php won't show

901

here's my code i don't know where i do wrong here

    <?php 
$conn=oci_connect("martin","123","localhost/XE");
If (!$conn)
    echo 'Failed to connect to Oracle';
else
    echo 'Succesfully connected with Oracle DB';?>
 <table border="1">
    <?php $stid = oci_parse($conn, "select*from MsNama");
        oci_execute($stid);

        while ($row = 
     oci_fetch_array(
         $stid,
         OCI_ASSOC+OCI_RETURN_NULLS)
 ) {?>
<tr>
    <td><?php echo $row[0]; ?></td>
    <td><?php echo $row[1]; ?></td>
    <td><?php echo $row[2]; ?></td>
</tr>
        <?php }?>

and here's my select on oracle database:

SQL> select * from MsNama
  2  ;
NAMA                      ANGKA G

this is what's it's look like this is what's it's look like

I changed the code with what i found on internet but still not working

{-code-3} 

i tried and always no result. nothing showing

600

Answer

-- -------- - martin 1 m|||<html> <head><title>Oracle demo</title> </head> <body> <?php $conn=oci_connect("martin","123","localhost/XE"); If (!$conn) echo 'Failed to connect to Oracle'; else echo 'Succesfully connected with Oracle DB'; ?> <table border="1"> <?php $stid = oci_parse($conn, "select * from MsNama"); oci_execute($stid,OCI_DEFAULT); while (oci_fetch($stid)) { $empno = oci_result($stid, "NAMA"); $ename = oci_result($stid, "angka"); $job = oci_result($stid, "gender"); ?> <tr> <td><?php echo $empno; ?></td> <td><?php echo $ename;?></td> <td><?php echo $job; ?></td> </tr> <?php }?> </table> </body> </html>
606

Answer

Solution:

oh my code not wrong but here's the code and it worked

<html>
<head><title>Oracle demo</title></head>
<body>
<?php 
$conn=oci_connect("martin","123","localhost/XE");
If (!$conn)
    echo 'Failed to connect to Oracle';
else
    echo 'Succesfully connected with Oracle DB';

 ?>
<table border="1">
<?php       $stid = oci_parse($conn, "select*from MsNama");
            $r=oci_execute($stid);

            while ($row = oci_fetch_array($stid, OCI_BOTH)) {?>
    <tr>
        <td><?php echo $row[0]; ?></td>
        <td><?php echo $row[1]; ?></td>
        <td><?php echo $row[2]; ?></td>
    </tr>
            <?php }?>
 </table>

 </body>
 </html>

the problem that i forgot to commit so .-.there's no result i'm sorry

People are also looking for solutions to the problem: php - iterating in groups resulted by a group by SQL statement

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.