Problems deleting mysql database

Asked

Viewed 44 times

0

Good morning people, I am creating a function to delete in the bank, but when I click the button it does not work, I would like some suggestion.

php requests.

    <?php
   $sqlCat = "SELECT cliente_id,cliente_nome,cliente_email,cliente_telefone,cliente_bairro,cliente_rua,cliente_complemento FROM cliente"; $tbCat = mysql_query($sqlCat) or die(mysql_error()); if(mysql_num_rows($tbCat) > 0){ while($rsCat = mysql_fetch_array($tbCat)){
?>


<tr>
  <td>1asdas</td>
  <td>aaaaaaa </td>
  <td> 3 </td>
  <td>4</td>
  <td>
    <?php echo $rsCat['cliente_nome'];?>
  </td>
  <td>
    <?php echo $rsCat['cliente_email'];?>
  </td>
  <td>
    <?php echo $rsCat['cliente_telefone'];?>
  </td>
  <td>
    <?php echo $rsCat['cliente_bairro'];?>
  </td>
  <td>
    <?php echo $rsCat['cliente_rua'];?>
  </td>
  <td>
    <?php echo $rsCat['cliente_complemento'];?>
  </td>

  <td class="td-actions"><a href="#" class="btn btn-small btn-success"><i class="btn-icon-only icon-edit"> </i></a>
    <a href="href=Pedidos_delete.php?deleta=<?php echo $rscat['cliente_id'];?>" title="Excluir"><img src="img/admin/icons/cross.png" alt="Excluir" /></a>

</tr>
<?php
    }
        }
  else
             {
  echo '<div class="alert alert-danger">
 <button type="button" class="close" data-dismiss="alert">x</button>
 <label><strong>ERRO!</strong> sem cadastro.</label>
 </div>';
  }



  ?>

  </tbody>

  </table>

Pedidos_delete.php (where I call the file to delete)

<?php
include_once('../scripts/config.php');
include_once('../scripts/funcoes.php');
include_once('seguranca.php');

$sql = "DELETE  FROM cliente WHERE cliente_id={ $_GET['idrecado]}";
$apagar = mysql_query($sql) or die (mysql_error());

echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=pedidos.php'>";
?>
  • It’s not about the question, but I advise you to use mysqli or PDO, the mysql extension has long since been abandoned. Regarding the question, have you tried to change the $_GET['idrecado'] for $_GET['deleta']?

1 answer

0


Change the GET to $_GET['deleta'], this way you’ll be picking up the value as you go.

href="href=Pedidos_delete.php?deleta=<?php echo $rscat['cliente_id'];?>" 

Also, note the code above, I think it’s wrong...

href="Pedidos_delete.php?deleta=<?php echo $rscat['cliente_id'];?>"

Browser other questions tagged

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