Delete table data without reloading page to update

-2

I have a table with data of a certain equipment, above the table has a field where the number of the equipment is inserted and quantity, the other information comes from the bank through the equipment number. In the last column of each table there is a button to exclude this line, but for that effect to occur it is necessary to reload the page. But once the user submits 1x, when the page is reloaded the browser understands the action as if there had been another submit, ie reinsert the last inserted product.

This is how the data is printed to the table

while ($result_info = mysql_fetch_array($sql_info))
    {
      $tabela .= '<tr>';
      $tabela .=    '<td>'.$result_info['cod_item'].'</td>';
      $tabela .=    '<td>'.$result_info['desc_item'].'</td>';
      $tabela .=    '<td>'.$result_info['unidade'].'</td>';
      $tabela .=    '<td>'.$result_info['quantidade'].'</td>';
      $tabela .=    '<td>'.$result_info['valor'].'</td>';
      $tabela .=    '<td><a onclick="needToConfirm = false;" style="margin-left: 30px;" title="Excluir" src="../../dist/icons/delete.png"></a></td>'; href="pecas_proposta_incluir_temp_del.php?id={$linhas["id_temp"]}"><img 
      $tabela .=    '</tr>';
    }
echo $tabela;

How can view data are concatenated into a variable, so that when the user enters more than one item, instead of overwriting the previous item it creates a new line.

In short, what I need is that the user can delete only the specified item and update it on time without the need to reload the page. If anyone has tips on how to reload the page without causing a submit again, I'll be grateful.

    
asked by anonymous 29.05.2018 / 18:57

1 answer

0
  

When you reload the page the browser understands the action as if there had been another submit, ie reinsert the last product inserted.

Classic error. You must create another PHP file to do the insertion, and once done, the user must be redirected to the previous page. That is, the PHP file that modifies the database should never be the same that shows the data on the screen to the user. This is MVC .

  

No need to reload the page.

For this you can use $ .ajax or $.post jQuery

    
29.05.2018 / 19:43