Delete rows from table

Asked

Viewed 359 times

1

I have a table with a list of registered debtors I want to rule him out if he pays. With a base I managed to create the function and everything, but when I update the page, it comes back.

<!-- FAZ A FUNÇÃO DE SALVAR OS DADOS -->
<?php
 header('Content-Type: text/html; charset=iso-8859-1');

 setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');

 date_default_timezone_set('America/Sao_Paulo');

$nome = $_POST['nome'];
$produto = $_POST['produto'];
$banco = "nova.txt";
if($_POST['acao'] == "CADASTRAR")
{
if(empty($nome)){echo"<script>window.location='cadastro.php';alert('Nome em branco!');</script>";}
elseif(empty($produto)){echo"<script>window.location='cadastro.php';alert('Selecione a venda!');</script>";}
else
{
$data = strftime('%A, %d de %B de %Y', strtotime('today'));
$arquivo = fopen("$banco","r");
$while = fread($arquivo,filesize($banco));
fclose($arquivo);
$abrir = fopen("$banco","w");
if($while == "0"){$salvar ="<table class='lista-clientes' width='100%'>       
<tbody>     
<tr>
<td align='center'></td>
<td> 
    <select class='select_styled'>
       <option value=''>$nome</option>
        <option value=''> Produto: $produto</option>
        <option value=''>Compra dia, $data</option>
</select
 </td>
 </tr>
 </tbody>
 </table>
";}
else{$salvar ="<table class='lista-clientes' width='100%'>       
<tbody>     
<tr>
<td align='center'></td>
<td> 
    <select class='select_styled'>
       <option value=''>$nome</option>
        <option value=''> Produto: $produto</option>
        <option value=''>Compra dia, $data</option>
</select>
 </td>
 </tr>
 </tbody>
 </table>
$while";}

fwrite($abrir,"$salvar");

fclose($abrir);

echo"<script>window.location='cadastro.php';alert('Cadastrado com Sucesso!');</script>";

}}
?>

<!-- FAZ A FUNÇÃO DE ABRIR OS DADOS-->

<?php

$arquivo = fopen($banco,"r");

$while = fread($arquivo,filesize($banco));

if($while == "0"){echo"<br><br><br><br><center><font face=verdana size=1>Nenhum recado inserido!</font></center><br><br><br><br>";}else{echo"<font face=verdana size=1>$while</font>";}

fclose($arquivo);?>	

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
(function($) {

  RemoveTableRow = function(handler) {
    var tr = $(handler).closest('table');

    tr.fadeOut(400, function(){ 
      tr.remove(); 
    }); 

    return false;
  };
})(jQuery);

</script>
<!-- faz a funçao de salvar os dados -->
<?php



 header('Content-Type: text/html; charset=iso-8859-1');

 setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');

 date_default_timezone_set('America/Sao_Paulo');

$nome = $_POST['nome'];
$produto = $_POST['produto'];
$banco = "nova.txt";
if($_POST['acao'] == "CADASTRAR")
{
if(empty($nome)){echo"<script>window.location='cadastro.php';alert('Nome em branco!');</script>";}
elseif(empty($produto)){echo"<script>window.location='cadastro.php';alert('Selecione a venda!');</script>";}
else
{
$data = strftime('%A, %d de %B de %Y', strtotime('today'));
$arquivo = fopen("$banco","r");
$while = fread($arquivo,filesize($banco));
fclose($arquivo);
$abrir = fopen("$banco","w");
if($while == "0"){$salvar ="<table class='lista-clientes' width='100%'>       
<tbody>     
<tr>
<td align='center'></td>
<td> 
    <select class='select_styled'>
       <option value=''>$nome</option>
        <option value=''> Produto: $produto</option>
        <option value=''>Compra dia, $data</option>
</select
 </td>
 </tr>
 </tbody>
 </table>
";}
else{$salvar ="<table class='lista-clientes' width='100%'>       
<tbody>     
<tr>
<td align='center'></td>
<td> 
    <select class='select_styled'>
       <option value=''>$nome</option>
        <option value=''> Produto: $produto</option>
        <option value=''>Compra dia, $data</option>
</select>
 </td>
 </tr>
 </tbody>
 </table>
$while";}

fwrite($abrir,"$salvar");

fclose($abrir);

echo"<script>window.location='cadastro.php';alert('Cadastrado com Sucesso!');</script>";

}}

?>


<!-- faz a função de abrir os dados -->
<?php

$arquivo = fopen($banco,"r");

$while = fread($arquivo,filesize($banco));

if($while == "0"){echo"<br><br><br><br><center><font face=verdana size=1>Nenhum recado inserido!</font></center><br><br><br><br>";}else{echo"<font face=verdana size=1>$while</font>";}

fclose($arquivo);?>	

I want to delete permanent or there is no way by Jquery?

  • 1

    You have to delete on the server... it’s not enough to delete on the browser. Where does this debtor list come from?

  • How simple is the dynamic in this I saved only in a text file and I call him on the site that sample this list.

  • But even that text file is on the right server? because you can’t save files with the browser.

  • yes, only that it saves all the records in the same file.

  • You can show the code you use when you use?

  • there is another way for me to put the code here on the site but specified?

  • Edit the question that gets better ;)

  • I still can’t ask right here, but I put all the dynamic used to save the data and show.

  • running only as shown. http://quetalumapizza.esy.es/lista_obligores.php

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.