php code to display dropdown data using oracle

 Below is the PHP code which shows the way to connect to Oracle and display data in dropdown

<?php

if ($conn =OCILogon("userName", "Password", "TNSNAME")) {
  echo "Successfully connected to Oracle.\n";
  OCILogoff($c);
} else {
  $err = OCIError();
  echo "Oracle Connect Error " . $err[text];
}
?>
<html>
<head>
<style type="text/css">
<!--
.style1 {color: #F65B00}

body{
    background-color:#ffffff;
    color: #000000;
    margin:5px;
    margin-right:5px;
     }
   
    </style>
</head>

<body >
<form name="policylist" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <table border="0" cellpadding="0" width="700">
  <tr>
   <td width="624">   
        <select name="policyname">
        <?php
            $query  = "select id,name from employee";
            $empid = OCIParse($conn, $query);
            OCIExecute($polid, OCI_DEFAULT);
             while ($succ_emp = OCIFetchInto($empid, $row)) {
                echo "<option value='".$row[0]."'>".$row[1]." - ". $row_pol[1]."</option> ";   
             }                           
                   
        ?>
        </select>
        </td>
        </tr>
        </table>
     </form>
</body>
</html>

<?php
 OCILogoff($conn);
?>

No comments:

Post a Comment