[Resolvido] Não excluir registro
Estou usando o Dreamweaver e meu problema é que não estou conseguindo apagar registro por checkboxs.
Primeiro criei um novo conjunto de registros, completei assim:
"
.Nome: RsCheckboxDeleteLink
.Conexão: "ip"
.Tabela: "ip_menuadmin"
.Coluna: 'Tudo'
.Filtro: "ma_id" > "=" > "Variável de formulário" > -- checkbox
"
Ok ...
Eu criei um novo "Excluir Registro", lá preenchi:
"
.Primeiro verifique se a variável está definida: "Variável de formulário" -- checkbox
.Conexão: "ip"
.Tabela: "ip_menuadmin"
.Coluna da chave primária: "ma_id"
.Valor de chave primária: "Variável de formulário" -- ma_id
.Após a exclusão, vá para: checkbox_delete.php?checkbox_menu=sucesso
"
OK ...
Parte do código (registros.php)
<table border="0" cellpadding="3" cellspacing="3">
<form id="form1" name="form1" method="post" action="checkbox_delete.php">
<tr>
<th><input type="checkbox" id="checkAll" />
<span class="style1">ID</span></th>
<th class="style1">Nome</th>
<th class="style1">Link</th>
</tr>
<?php do { ?>
<tr>
<td><input type="checkbox" name="checkbox[]" value="<?php echo $row_RsListaMenu['ma_id']; ?>" />
<?php echo $row_RsListaMenu['ma_id']; ?></td>
<td><?php echo $row_RsListaMenu['ma_label']; ?></td>
<td><?php echo $row_RsListaMenu['ma_value']; ?></td>
</tr>
<?php } while ($row_RsListaMenu = mysql_fetch_assoc($RsListaMenu)); ?>
<tr>
<td><input type="submit" name="submit" id="submit" value="Excluir" /></td>
<th> </th>
<th> </th>
</tr>
</form>
</table>
Página de exclusão com botão Confirmar e Cancelar (checkbox_delete.php)
<?php require_once('conexao/conexao/ip.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
if ((isset($_POST['ma_id'])) && ($_POST['ma_id'] != "") && (isset($_POST['checkbox']))) {
$deleteSQL = sprintf("DELETE FROM ip_menuadmin WHERE ma_id=%s",
GetSQLValueString($_POST['ma_id'], "int"));
mysql_select_db($database_ip, $ip);
$Result1 = mysql_query($deleteSQL, $ip) or die(mysql_error());
$deleteGoTo = "admin_menu_checkbox_delete.php?checkbox_menu=sucesso";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_RsCheckboxDeleteLink = "-1";
if (isset($_POST['checkbox'])) {
$colname_RsCheckboxDeleteLink = $_POST['checkbox'];
}
mysql_select_db($database_ip, $ip);
$query_RsCheckboxDeleteLink = sprintf("SELECT * FROM ip_menuadmin WHERE ma_id = %s", GetSQLValueString($colname_RsCheckboxDeleteLink, "int"));
$RsCheckboxDeleteLink = mysql_query($query_RsCheckboxDeleteLink, $ip) or die(mysql_error());
$row_RsCheckboxDeleteLink = mysql_fetch_assoc($RsCheckboxDeleteLink);
$totalRows_RsCheckboxDeleteLink = mysql_num_rows($RsCheckboxDeleteLink);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Excluindo</title>
<style type="text/css">
<!--
#form1 {
text-align: center;
}
.style1 {
color: #C33;
font-weight: bold;
font-size: 16;
text-align: center;
}
.style2 {
text-align: center;
}
.style1 {
font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
if($_GET['checkbox_menu'] == "sucesso") { ?>
<p class="style1"> Sucesso!!!</p>
<p class="style2"><a href="javascript:window.opener.location='admin_menu.php';close();" title="Fechar e autualizar">Fechar</a></p>
<?php } else { ?>
<table width="400" border="0">
<tr>
<td>Apagando o(s) link(s) do checkbox(s) selecionado(s) (<strong> <?php echo $row_RsCheckboxDeleteLink['ma_label']; ?> </strong>)</td>
</tr>
<tr>
<td><form id="form1" name="form1" method="post" action="admin_menu_checkbox_delete.php?checkbox=<?php echo $row_RsCheckboxDeleteLink['ma_id']; ?>">
<input name="ma_id" type="hidden" id="ma_id" value="<?php echo $row_RsCheckboxDeleteLink['ma_id']; ?>" />
<input type="button" name="Cancelar" id="Cancelar" value="Cancelar" onclick="javascript:window.close()" />
<input type="submit" name="Submit" id="Submit" value="Confirmar" />
</form></td>
</tr>
</table>
<?php } ?>
</body>
</html>
<?php
mysql_free_result($RsCheckboxDeleteLink);
?>
Quando aperto em no botão Excluir em registros.php sou direcionado para a página de exclusão e ao apertar no em Confirmar não exclue o registro do checkbox selecionado, apenas muda de URL (../checkbox_delete.php?checkbox=). O que está ocorrendo?
Discussão (17)
Carregando comentários...