Ver Mensaje Individual
  #17 (permalink)  
Antiguo 02/01/2006, 11:41
Avatar de calavera
calavera
 
Fecha de Ingreso: diciembre-2005
Mensajes: 113
Antigüedad: 18 años, 3 meses
Puntos: 0
Mensaje

hola amigos e hecho los cambios que me han sujerido, pero aun no me elimina varios registros a la vez, caso contrario es cuando elimino 1 por 1, si alguien puede aportar otras variantes se los agradeceria muchisimo
aqui esta el codigo completo muevamente con sus modificaciones



Código PHP:
codigo de borra.php
<body bgcolor="#2C89AD">
<table width="792" height="38" border="0">
  <!--DWLayoutTable-->
  <tr> 
    <td width="786" height="34" valign="top" bgcolor=eec236> <p align="center"><font color="#000000" size="5" ><strong>Eliminar</strong></font></td>
    </tr>
</table>
<?php
   
include("conex.php");
   
$link=Conectarse();
   
$result=mysql_query("select * from Equipos",$link);
   
   
   
$base="Test";
   
$link=mysql_connect("localhost","root");
   
mysql_select_db($base,$link);
   if (!isset(
$pg))
    
$pg 0// $pg es la pagina actual
    
$cantidad=10// cantidad de resultados por página
    
$inicial $pg $cantidad;

    
$pegar = ("SELECT * FROM Equipos ORDER BY Id_Equipos LIMIT $inicial,$cantidad");
    
$result mysql_db_query($base,$pegar) or die (mysql_error());

    
$contar = ("SELECT * FROM Equipos ORDER BY Id_Equipos"); 
    
$contarokmysql_db_query($base,$contar);
    
$total_records mysql_num_rows($contarok);
    
$pages intval($total_records $cantidad);
?>
<tr></tr>
 
<td width="800" height="28" valign="top">&nbsp;</td>
  </tr>
  <tr>
  <tr>
  <tr>
  </tr></tr></tr>
    
<TABLE width="797" height="54" BORDER=1 CELLPADDING=1 CELLSPACING=1>
  <!--DWLayoutTable-->
  <TR> 
    <td width="110" height="23"> <div align="justify">&nbsp;<font size="3"><strong>ACCIONES&nbsp;</strong></font></div></TD>
    <td width="64">&nbsp;</td>
    <td width="25">&nbsp;</td>
    <td width="38">&nbsp;</td>
    <td width="40">&nbsp;</td>
    <td width="46">&nbsp;</td>
    <td width="64">&nbsp;</td>
    <td width="129">&nbsp;</td>
    <td width="88">&nbsp;</td>
    <td width="92">&nbsp;</td>
    <td width="81">&nbsp;</td>
  <TR> 
    <td height="28"></td>
    <TD valign="top"><div align="left"><font size="1"><font size="1">&nbsp;Id_Equipos</font></font></div></TD>
    <TD valign="top"><div align="left"><font size="1">&nbsp;Tipo</font><font size="2"><strong></strong></font></div>
    <TD valign="top"><div align="left"><font size="1">&nbsp;Marca&nbsp;</font></div>
    <TD valign="top"><div align="left"><font size="2"><font size="1">&nbsp;Modelo</font></font></div>
    <TD valign="top"><div align="left"><font size="1">&nbsp;N_Serie</font><font size="2"><strong></strong></font></div></TD>
    <TD valign="top"><div align="justify"><font size="1">&nbsp;Descripción</font><font size="2"><strong></strong></font></div></TD>
    <TD valign="top"><div align="left"><font size="1">Fecha_ Compra</font><font size="2"><strong></strong></font></div></TD>
    <TD valign="top"><div align="left"><font size="1">&nbsp;N_Factura</font><font size="2"></font></div></TD>
    <TD valign="top"><div align="left"><font size="1">&nbsp;Rut_ Proveedor</font></div></TD>
    <TD valign="top"><div align="left"><font size="1">&nbsp;Rut_Asignado</font></div></TD>
  </TR>
  <?php       


echo("<form name='form1' method='post' action='BorraMultiple.php'>");
echo(
"<input name='submit' type='submit' value='Borrar Seleccionado'>");  
      
   while(
$row mysql_fetch_array($result)) { 
   
        echo (
"<tr><td><input type='checkbox' name='Id_Equipos[]' value='$row[Id_Equipos]'><a onclick='confirmDel(); 'href=\"BorradoSql.php?Id_Equipos=".$row["Id_Equipos"]."\">Eliminar</a>                                        
                </td><td>"
.$row["Id_Equipos"]."</td><td>".$row["Tipo"]."</td><td>".$row["Marca"]."</td>
                <td>"
.$row["Modelo"]."</td><td>".$row["N_Serie"]."</td><td>".$row["Descripcion"]."</td>
                <td>"
.$row["Fecha_Compra"]."</td><td>".$row["N_Factura"]."</td><td>".$row["Rut_Proveedor"]."</td>
                <td>"
.$row["Rut_Asignado"]."</td></tr>"); 
         } 
echo(
"</form>");

     
mysql_free_result($result); 
     
mysql_close($link);   
     
     
     echo (
"<p class=fonty center>"); 
     
                if (
$pg != 0) { 
                    
$url $pg 1
                        echo (
"<a href='$PHP_SELF?pg=".$url."'>&laquo;Anterior</a>"); 
                              }
                              else { 
                                echo (
" "); 
                              } 
                    for (
$i 0$i <= $pages$i++) { 
                        if (
$i == $pg) { 
                            if (
$i == "0") { 
                        echo (
"<b> 1 </b>"); 
                                           }
                                 else { 
                                        
$i $i+1
                                            echo (
"<b> ".$i." </b>"); 
                                       } 
                                      }
                                        else { 
                                            if (
$i == "0") { 
                                            echo (
"<a href='$PHP_SELF?pg=".$i."'>1</a> "); 
                                     } 
                                             else { 
                                            echo (
"<a href='$PHP_SELF?pg=".$i."'>"); 
                                            
$i $i+1
                                            echo (
" ".$i." </a>"); 
                                            } 
                                                          } 
                                                } 
                                            if (
$pg $pages) { 
                                            
$url $pg 1
                                            echo (
"<a href='$PHP_SELF?pg=".$url."'>Siguiente&raquo;</a>"); 
                                                              }
                                                               else { 
                                                                echo (
" "); 
                                                                    } 
                                                                echo (
"</p>"); 
 
?>
</table>

<table width="772" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr> 
    <td width="125" height="29"></td>
    <td width="176"></td>
    <td width="51"></td>
    <td width="420"></td>
  </tr>
  <tr> 
    <td rowspan="2" valign="top"> <form name="form1" method="post" action="BorraMultiple.php">
        
      </form></td>

   
   

    <td height="16"></td>
    <td valign="top"><div align="center"><a href="Equipos.php"><strong><font size="2"> 
        Volver </font></strong></a></div></td>
    <td></td>
  </tr>
  <tr>
    <td height="4"></td>
    <td></td>
    <td></td>
  </tr>
  <tr> 
    <td height="46">&nbsp;</td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>
Código PHP:
codigo BorraMultiple.php
<?php 
     
include("conex.php");
   
$link=Conectarse();
   
$result=mysql_query("select * from Equipos",$link);    

// Generamos una lista de los ID's (campo value= ..) que tenemos en nuestro array. 
if(count($_POST['Id_Equipos']) > 1) {
$lista implode(','$_POST['Id_Equipos']);
}
else {
$lista =($_POST['Id_Equipos'][0]);
}

// Y lo aplicamos al SQL correspondiente y ejecutamos la consulta. 
mysql_query("DELETE * FROM Equipos WHERE Id_Equipos IN(".$lista.")",$link); 

mysql_free_result($result); 
mysql_close($link);   

header('Location: Equipos.php');
?>

aun no comprendo lo ke hay ke hacer para poder eliminar varios registros a traves de un checkbox

Muchas gracias por toda la ayuda ke me han entregado durante todo este corto tiempo

Cita:
Iniciado por Dwar
mira tengo una duda el campo en la base de datos llama igual en mayusculas y minusculas??

si es asi yo cambiaria esta linea

echo ("<tr><td><input type='checkbox' name='Id_Equipos[$Id_equipos]'><a onclick='confirmDel(); 'href=\"BorradoSql.php?Id_Equipos=".$row["Id_Equipos"]."\">Eliminar</a>

por esta otra

echo ("<tr><td><input type='checkbox' name='Id_Equipos[]' value='$row[Id_Equipos]'>


fijate que tambien le quito las comillas del subindice del arreglo $row