View data in Array

0

I am doing a query in a database and I need to display the information on the screen, but searching one by one. I tried to do it by array, but it is not displaying the vector.

Code:

<?php
$a = $_GET['a'];
if($a == "buscar"){
  $id = $_POST['id'];
  $sql = ibase_query("SELECT NOME FROM TB_CLIENTE WHERE ID_CLIENTE LIKE '%".$id."%'");
  $row = ibase_fetch_row($sql);
  $vetorDados = array();
  $i=0;
  $vetorDados[$i]= ibase_fetch_row($sql);
  echo '<tr>';
  echo '<td>' . $vetorDados[$i] . '</td>';
  echo '<td>' . $i . '</td>';
  echo '</tr>';
  $i++;
}
?>
    
asked by anonymous 17.10.2017 / 17:24

1 answer

3

You did not create a while to display data, another detail that became redundant was you create a $vetorDados array to print the result of the database, and the $row variable is already a array , below the code to display the bank's data.

<?php
$a = $_GET['a'];
if($a == "buscar"){
$id = $_POST['id'];
$sql = ibase_query("SELECT NOME FROM TB_CLIENTE WHERE ID_CLIENTE LIKE '%".$id."%'");
$i = 1;
while($row = ibase_fetch_row($sql)){
   echo "<tr>";
   echo "<td>{$row['NOME']}</td>";
   echo "<td>{$i}</td>"; 
   echo "</tr>";
   $i++;
   }    
}
?>

The key of the $row variable is the name of the bank column to which you want to print the information.

    
17.10.2017 / 18:42