Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/06/2009, 16:23
Avatar de Superlinux
Superlinux
 
Fecha de Ingreso: octubre-2005
Ubicación: Colombia
Mensajes: 662
Antigüedad: 19 años, 5 meses
Puntos: 1
Pregunta eliminar varios .. o todos los item

algo le pasa .. ha esta funcion no me permite eliminar varios ni todos los item ...

vendedores.php
Código PHP:
<?php
//Por medio de esta función inicializo la sesion
session_start();

//Archivo de conexion
require("connect.php");

if(!
$_SESSION[idsession] || !$_SESSION[login] || !$_SESSION[password])
{
    print 
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=error2.php\">";
}else{    
    
    
//_______Obtención y paginado de mensajes________
    
    // Compruebo la página donde estoy.
    
if ($_GET['pagina'] == "" || $_GET['pagina'] == 0)
    {
        
$_GET['pagina'] = 1;
    }
//Fin del if
    

    
$cantRegistros $sql->cantidadRegistros("regvendedor","IdVendedor","");

    
$paginado =  $objGeneral->paginado($cantRegistros20$_GET['pagina']);
    
    
$regvendedor $sql->listar("regvendedor""*""IdVendedor""IdVendedor, nombres, apellidos, cedula"$paginado['limitInf'], 20);
    
    
$space "&nbsp;&nbsp;&nbsp;&nbsp;";
    
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Vendedores</title>

<style type="text/css">
<!--
body {
    background-image: url(img/fondo_principal.gif);
}
-->
</style>

<link href="css/estilos_aqua.css" rel="stylesheet" type="text/css" />

<SCRIPT Language="JavaScript">
<!--
function imgChange(id, img)
{
    id.src = img;
}//Fin function

function setAction(valor)
{
    document.form.action.value = valor;
}//Fin function
//--> 
</SCRIPT>

<style type="text/css">
<!--
.Estilo3 {font-size: 24px}
-->
</style>

<SCRIPT LANGUAGE="JavaScript">
<!-- Selecciono o Desmarco Varios Checkbox al mismo tiempo
var checkflag = "false";
function check(field) {
    if (checkflag == "false") {
        for (i = 0; i < field.length; i++) {
            field[i].checked = true;}
            checkflag = "true";
        return "Uncheck All"; }
    else {
        for (i = 0; i < field.length; i++) {
        field[i].checked = false; }
        checkflag = "false";
    return "Check All"; }
}//Fin function
// End -->
</script>

</head>

<body>
<form action="vendedores_script.php" method="post" name="form">
<input name="action" type="hidden" value="null" />
<table width="840" border="0" align="center" cellpadding="0" cellspacing="0" >
  <tr class="td_gray_header">
    <td colspan="4" valign="middle" scope="row"><table width="100%" height="63" border="0" align="center">
      <tr>
        <th width="29%" height="59" scope="row"><div align="left"><a href="add_vendedores.php"><img src="../img/boton_agregar.png" width="113" height="60" border="0" align="absmiddle"  alt="Add"/></a>
                <input name="image" type="image" onMouseDown="javascript: setAction('drop');" src="../img/boton_eliminar.png" alt="Delete" align="absmiddle" />
        </div></th>
        <th scope="row">&nbsp;</th>
        </tr>
    </table></td>
    </tr>
  <tr class="td_title_aqua">
    <td width="3%" valign="middle" scope="row"><div align="center">
      <input type="checkbox" name="SLT_ALL" value="Check All" onClick="this.value=check(this.form.lista)">
    </div></td>
    <td width="8%" valign="middle" scope="row">Id</td>
    <td width="16%" height="20" valign="middle" scope="row">Cedula</td>
    <td width="73%" valign="middle" scope="row">Nombre</td>
    </tr>
<?php

// ---------- NEW CUSTOMERS LIST ---------------------------------------

if($regvendedor)
{
    
$c=0;        
        foreach(
$regvendedor as $regven)
        {
        
            
$nombre$regven["nombres"].' '.$regven["apellidos"];
            
$ID$regven["IdVendedor"];
            
            if(
$c%2==0//td list styles
            
{  $class=  "td_white" ;   }
            else
            {  
$class=  "td_orange" ;  }
            
            
$c++;
      
            
?>    
              <tr class="<?php echo $class ?>">
                <td><div align="center"><input name="lista[]" type="checkbox" id="lista" value="<?php echo $ID?>"></div></td>
                <td  scope="row"><div align="left"><a href="add_vendedores.php?id=<?php echo $ID;  ?>" class="enlace"><?php echo $ID?></a></div></td>
                <td  scope="row"><div align="left"><a href="add_vendedores.php?id=<?php echo $ID;  ?>" class="enlace"><?php echo $regven['cedula']; ?></a></div></td>
                <td  scope="row"><div align="left"><?php echo $nombre?></div></td>
              </tr>
             <?php
         
               
}//Fin del foreach
}else
{
    echo 
"<p align=\"center\" ><strong> No hay nuevos registros</strong> </p>";
}
//Fin del if
?>    
</table>
</form>
</body>
</html>
<?php
}//Fin del if
?>

vendedores_script.php
Código PHP:
<?php 
session_start
();

//Archivo de conexion
require("connect.php");

if(!
$_SESSION[idsession] || !$_SESSION[login] || !$_SESSION[password])
{
    print 
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=error2.php\">";
}else{    
 
 if (
$_POST['action']=='drop')
 {
     
//obtiene en un arreglo los registros que fueron seleccionados para borrar
    
$checked$_POST['lista'];
    
    
//borra cada registro seleccionado en el checkbox
    
if($checked)
    {
        foreach (
$checked as $id
        {
         
$sql->eliminar("regvendedor""IdVendedor =".$id);
         
         
$sql "alter TABLE regvendedor auto_increment = $id"
         
$res mysql_query($sql);
         
         
//Visualiza mensaje    
        
?>
        <script>
              location="vendedores.php";
             alert ("¡ El registro fue eliminado con exito !.");  
        </script>
        <?php
        
}//Fin del foreach 
        
        //Redireccionamiento
        
        
header("Location: vendedores.php");
        exit();
    
    }else{
       
//Redireccionamiento
        
        
header("Location: vendedores.php");
        exit();
    }
  }
}
?>
__________________
"La vida sigue su curso, tú toma parte de ella."