Display data in PHP table

1

I am doing a sales report and need to organize the data coming from a bank in firebird to make a report in PHP , but I am not able to know how much data is coming from the bank. Because the ibase_num_fields function does not return how many data it is. And then how would you organize the data in a table?

   $host='localhost:C:/bd_relatorio/clipp.FDB';    

   $dbh=ibase_connect($host,'SYSDBA','masterkey');

   $stmt = 'SELECT NOME FROM TB_CLIENTE';

   $sth = ibase_query($dbh, $stmt);   

   $total = ibase_num_fields($sth);

   if($total > 2){

     while ($row = ibase_fetch_row($sth)) {
         echo $row[0], "\n";
     }
   }
   echo $total;
   ibase_free_result($sth);
   ibase_close($dbh);
?>
    
asked by anonymous 13.10.2017 / 20:25

2 answers

2

There is no function in the ibase_ library that returns the number of rows in a query.

There are two options:

  • The first SQL path is to execute the same query with a count() .

  • The second via PHP is to create a variable that stores the number of lines, something like:

-

$totalLinhas = 0;
if($sth){
   while ($row = ibase_fetch_row($sth)) {
      echo $row[0], "\n";
      $totalLinhas++;
   }
   echo "total: ". $totalLinhas;
}
    
13.10.2017 / 20:37
0

// counting received lines in the array $ total = ibase_num_rows ($ sth);

// loop in the array, assembling the rows of the table. // Just print the variable

while($row = ibase_fetch_object($sth))
{
  $linhas = '<tr><td>Clientes: '. $row->NOME .'</td></tr>';
}
    
13.10.2017 / 20:50