Hola, tengo el siguiente problema y espero me puedan ayudar a encontrar el error:
Quiero realizar la consulta de una base de datos y posteriormente actualizar algunos campos; el problema que tengo es de que
en el momento de actualizar solo me actualiza la primera fila, abajo dejo mis codigo para que este un poco mas claro.
OBTENGO VALORES DE BASE DE DATOS
Código PHP:
include('conexion.php');
$sql = "SELECT ID, FolSeg, Fecha, Prov, FacFol, Importe, Status, Comentario, DFactura, DPO, DSoporte, DXML FROM CXPD";
mysql_query("SET NAMES 'utf8'");
$result = mysql_query ($sql);
if (! $result){
echo "La consulta SQL contiene errores.".mysql_error();
exit();
}else {
echo " <table>
<thead>
<tr>
<th width=30>ID</th>
<th width=100>Fecha</th>
<th width=50>Nombre</th>
<th width=50>Correo</th>
<th width=100>Proyecto</th>
<th width=100>Folio</th>
<th width=100>Folio</th>
<th width=100>Folio</th>
<th width=100>Folio</th>
<th width=100>Folio</th>
<th width=100>Folio</th>
<th width=100>Folio</th>
</tr>
</thead>";
while ($row = mysql_fetch_row($result)){
echo "
<form method='POST' action='form1.php'>
<td><input type='text' name='ID[]' size='20' value=$row[0] readonly></td>
<td><input type='text' name='da1[]' size='20' value=$row[1] readonly></td>
<td><input type='text' name='da2[]' size='20' value=$row[2] readonly></td>
<td><input type='text' name='da3[]' size='20' value=$row[3] readonly></td>
<td><input type='text' name='da4[]' size='20' value=$row[4] readonly></td>
<td><input type='text' name='da5[]' size='20' value=$row[5] readonly></td>
<td><input type='text' name='da6[]' size='20' value=$row[6] readonly></td>
<td><input name='StatusF1[]' type='checkbox' value='APROBADA'>A</td>
<td><input name='StatusF1[]' type='checkbox' value='CANCELADA'>C</td>
<td><input type='text' name='Comentario[]' size='20' value=$row[7] readonly></td>
<td><input type='text' name='da8[]' size='20' value=$row[8] readonly></td>
<td><input type='text' name='da9[]' size='20' value=$row[9] readonly></td>
<td><input type='text' name='da10[]' size='20' value=$row[10] readonly></td>
<td><input type='text' name='da11[]' size='20' value=$row[11] readonly></td>
</tr>
";
}
echo
"</table><input type='submit' value='Actualizar datos' name='update'></td> ";
}
mysql_close();
Actualizo BASE DE DATOS
Código PHP:
$ID= array();
$StatusF1= array();
$Comentario= array();
foreach($_POST['ID'] as $key=>$value)
$ID[]= $value;
foreach($_POST['StatusF1'] as $value)
$StatusF1[]= $value;
foreach($_POST['Comentario'] as $key=>$value)
$Comentario[]= $value;
for($i=0; $i<count($StatusF1); $i++)
{
include "conexion.php";
$sSQL="Update CXPD Set Status='$StatusF1[$i]',Comentario='$Comentario[$i]' where ID='$ID[$i]'";
mysql_query($sSQL)or die(mysql_error());
}
ASI ME APARECE LA BASE DE DATOS
CUANDO SELECCIONO LOS CAMPOS A ACTUALIZAR NO ACTUALIZA SOLO LOS PRIMEROS