Advertisement
pepoflex

Conexion PHP y Oracle DB

Aug 10th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. $conn = oci_pconnect('user', 'pass', 'localhost/XE');
  4. if (!$conn) {
  5.     $e = oci_error();
  6.     trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
  7. }
  8.  
  9. $stid = oci_parse($conn, 'SELECT * FROM zapatos');
  10. oci_execute($stid);
  11.  
  12. echo "<table class='table table-striped'>\n";
  13. echo "<thead>";
  14. echo "<tr>";
  15. echo "<th>ID</th>";
  16. echo "<th>Nombre</th>";
  17. echo "<th>Precio</th>";
  18. echo "<th>Stock</th>";
  19. echo "<th>Detalles</th>";
  20. echo "</tr>";
  21. echo "</thead>";
  22. while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
  23.     echo "<tr>\n";
  24.     foreach ($row as $item) {
  25.         echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "") . "</td>\n";
  26.     }
  27.     echo "</tr>\n";
  28. }
  29. echo "</table>\n";
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement