Hola a todos, tengo un problemilla...
No puedo eliminar registros de la base de datos
tengo el siguiente codigo que me lista todos los registros para seleccionar los que quiera eliminar...
echo"<center>";
echo"<center><img src='image002.gif' width='131' height='47' /></center>";
echo"<strong>MASA - Mecánicos Asociados S.A.</strong>";
echo"<br>";
echo"<strong>891102723-8</strong>";
echo"<br><br>";
echo "<form action='eliminar.php' method='post' name='form1'>";
echo "<table border = 2>";
echo "<tr><td><strong><center>Eliminar</center></strong></td><td><center><strong>Cedula</center></strong></td><td><center><strong>Nombre</center></strong></td><td><center><strong>Cargo</center></strong></td><td><center><strong>Contrato</center></strong></td><td><center><strong>Email</center></strong></td><td><center><strong>Visible</center></strong></td><td><center><strong>Activo</center></strong></td>";
$sql="select * from contratos";
$registros = mysql_query($sql);
$c=1;
$cantreg=mysql_num_rows($registros);
while($row2=mysql_fetch_array($registros))
{
$arregcedula[$c-1]=$row2["cedula"];
$nom="chk".$c;
echo "<tr><td><input type='checkbox' name='$nom' value=1></td>";
echo "<td>"; echo $row2["cedula"];
echo "</td>";
echo "<td>"; echo $row2["nombre"];
echo "</td>";
echo "<td>"; echo $row2["cargo"];
echo "</td>";
echo "<td>"; echo $row2["contrato"];
echo "</td>";
echo "<td>"; echo $row2["email"];
echo "</td>";
echo "<td>"; if ($row2['visible']=='1') echo"<img src='check.png' width='25' height='20'/>";
elseif ($row2['visible']=='0'){echo"<img src='nocheck.png' width='25' height='20'/>";}//echo $row2["visible"];
echo "</td>";
echo "<td>"; if ($row2['activo']=='1') echo"<img src='check.png' width='25' height='20'/>";
elseif ($row2['activo']=='0'){echo"<img src='nocheck.png' width='25' height='20'/>";}//echo $row2["activo"];
echo"</td></tr>";
$c++;
}
echo "</table></center><br>
<center><input type=submit name=elim value=Eliminar></center>
</form>";
echo"<center><form name='form1' method='post' action='contratos.php'>";
echo"<input type='submit' name='Submit' value='<< Volver'>";
echo"</form></center>";
el archivo eliminar.php
require_once ("conexion.php");
$link=conectarse();
for($c=1;$c<=$cantreg;$c++)
{
$nom="chk".$c;
if($nom==1)
{
$sql="delete from contratos where cedula='".$arregcedula[$c-1]."'";
mysql_query($sql,$link);
}
}
echo"<center>";
echo"<center><img src='image002.gif' width='131' height='47' /></center>";
echo"<strong>MASA - Mecánicos Asociados S.A.</strong>";
echo"<br>";
echo"<strong>891102723-8</strong>";
echo"<br><br>";
echo"<strong><em>Los datos seleccionados han sido eliminados</strong></em>";
echo"<form name='form1' method='post' action='contratos.php'>";
echo"<input type='submit' name='Submit' value='<< Volver'>";
echo"</form><center>";
?>