Foros del Web » Programando para Internet » PHP »

Codigo eliminar en php ayuda

Estas en el tema de Codigo eliminar en php ayuda en el foro de PHP en Foros del Web. Hola estoy tratando de hacer funcionar este código para eliminar datos en PHP creado con dreamweaver y por algún motivo no logro hacer que funcione ...
  #1 (permalink)  
Antiguo 22/03/2010, 21:45
 
Fecha de Ingreso: marzo-2010
Mensajes: 5
Antigüedad: 14 años, 1 mes
Puntos: 0
Codigo eliminar en php ayuda

Hola estoy tratando de hacer funcionar este código para eliminar datos en PHP creado con dreamweaver y por algún motivo no logro hacer que funcione si alguien me puede ayudar de antemano muchas gracias.
Código HTML:
<?php require_once('../Connections/lastrega.php'); ?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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($_GET['id_apert'])) && ($_GET['id_apert'] != "") && (isset($_GET['recordID']))) {
  $deleteSQL = sprintf("DELETE FROM aperitivos WHERE id_apert=%s",
                       GetSQLValueString($_GET['id_apert'], "int"));

  mysql_select_db($database_lastrega, $lastrega);
  $Result1 = mysql_query($deleteSQL, $lastrega) or die(mysql_error());

  $deleteGoTo = "eliminar_apert.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}

$maxRows_DetailRS1 = 10;
$pageNum_DetailRS1 = 0;
if (isset($_GET['pageNum_DetailRS1'])) {
  $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
}
$startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;

$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
  $colname_DetailRS1 = $_GET['recordID'];
}
mysql_select_db($database_lastrega, $lastrega);
$query_DetailRS1 = sprintf("SELECT * FROM aperitivos WHERE id_apert = %s", GetSQLValueString($colname_DetailRS1, "int"));
$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
$DetailRS1 = mysql_query($query_limit_DetailRS1, $lastrega) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);

if (isset($_GET['totalRows_DetailRS1'])) {
  $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
} else {
  $all_DetailRS1 = mysql_query($query_DetailRS1);
  $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
}
$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
?>
 <form id="form1" name="form1" method="post" action="eliminar_apert.php">
        <input name="id_apert" type="hidden" id="id_apert" value="<?php echo $row_DetailRS1['id_apert']; ?>" /> 
        <table border="1" align="center">
          <tr>
            <td width="61"><div align="right">ID Aperitivo:</div></td>
            <td width="112"><?php echo $row_DetailRS1['id_apert']; ?> </td>
          </tr>
          <tr>
            <td><div align="right">Nombre:</div></td>
            <td><?php echo $row_DetailRS1['nom_apert']; ?> </td>
          </tr>
          <tr>
            <td><div align="right">Precio:</div></td>
            <td><?php echo $row_DetailRS1['precio_apert']; ?> </td>
          </tr>
          <tr> </tr>
        </table>
        <label>
        <div align="center">
          <input type="submit" name="button" id="button" value="Eliminar" />
        </div>
        </label>
    </form>
<?php
mysql_free_result($DetailRS1);
?> 

Etiquetas: eliminar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:45.