I have a doubt is that I want to get a table in html and print all the data of a table in oracle, but I can't do it.
<?php
function conectar_Oracle($usuario, $pass, $cadenaconexion)
{
// Conectar con Oracle:
$conexion = oci_connect($usuario, $pass, $cadenaconexion) or die("Error al conectar : " . oci_error());
return $conexion;
}
$conexion = conectar_Oracle(
"system",
"password",
"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=puvidb)))"
);
$sql = "SELECT * FROM GENERAL.PERSONAGENERAL ORDER BY 'PAGE_ID'";
$filas = 0;
$stmt = oci_parse($conexion, $sql);
$ok = oci_execute($stmt);
$obj = oci_fetch_object($stmt);
echo $obj->PEGE_ID . " - " . $obj->PEGE_DOCUMENTOIDENTIDAD . " - " . $obj->PEGE_MAIL . "<br />";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<table border="1">
<thead>
<tr>
<th>#</th>
<th>Codigo</th>
<th>Producto</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
foreach ($obj as $dato) {
?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $obj->PEGE_ID; ?></td>
<td><?php echo $obj->PEGE_DOCUMENTOIDENTIDAD; ?></td>
<td><?php echo $obj->PEGE_MAIL; ?></td>
</tr>
<?php
}
?>
</tbody>
</div>
</table>
</body>
</html>
Well, I get it to bring me data when I specify it, but it doesn't bring me the whole table, it means that the connection seems to be all right, I'm very used to connecting with MySQL but Oracle has had many problems.
Here is the result, if you realize it repeats the data and does not bring me the rest, I have to say that this DB has about 2500 records
The fault is that the foreach is badly done and since the variables that were defined there do not work. the code would be like this.