Search various PHP database items

0

I'm having the following problem with PHP , I'm doing a search on a Firebird database so that I can issue a report with sales orders.

I will enter the order IDs one by one and will return the values for me. However, every time I do the search it deletes the existing data, leaving only the last value searched.

<?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);
     echo '<tr>';
     echo '<td>' . $row[0] . '</td>';
     echo '<td>' . $id . '</td>';
     echo '</tr>';
}
?>

Can anyone help me? (in the Queries is looking for the name of the client only as an example, then I will change to the data of the request, thus it is easier to visualize)

    
asked by anonymous 16.10.2017 / 20:16

1 answer

0

ibase_fecth_row only returns one line at a time. If you want more than one, you can put the ibase_fetch_row call on a repeat loop, to cycle through the entire resultset. It looks more or less like this

//........
$sql = ibase_query("SELECT NOME FROM TB_CLIENTE WHERE ID_CLIENTE LIKE '%".$id."%'");
     while($row = ibase_fetch_row($sql)){
     echo '<tr>';
     echo '<td>' . $row[0] . '</td>';
     echo '<td>' . $id . '</td>';

     echo '</tr>';
}
    
17.10.2017 / 01:32