Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/12/2007, 07:15
fisad
 
Fecha de Ingreso: diciembre-2007
Mensajes: 19
Antigüedad: 16 años, 5 meses
Puntos: 0
Pregunta Re: Referenciar celdas con id para usarlos en mysql

Estimado: Mi código de generación de la tabla desde una consulta es:

<?php
if (mysql_num_rows($matriz) > 0){
echo "<table id='tabladatos' border = '1'> \n";
echo "<tr>
<td></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>A</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>B</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>C</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>D</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>E</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>F</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>G</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>H</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>I</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>J</strong></td>
</tr>";

$L=1;
while ($fila = mysql_fetch_row($matriz))
{
echo "<tr>";
echo "<td width='20' align='center' bgcolor='#CCCCCC'><strong>$L</strong></td>";
echo "<td width='20' align='center' id='A".$L."'>".$fila[0]."</td>";
echo "<td width='20' align='center' id='B".$L."'>".$fila[1]."</td>";
echo "<td width='20' align='center' id='C".$L."'>".$fila[2]."</td>";
echo "<td width='20' align='center' id='D".$L."'>".$fila[3]."</td>";
echo "<td width='20' align='center' id='E".$L."'>".$fila[4]."</td>";
echo "<td width='20' align='center' id='F".$L."'>".$fila[5]."</td>";
echo "<td width='20' align='center' id='G".$L."'>".$fila[6]."</td>";
echo "<td width='20' align='center' id='H".$L."'>".$fila[7]."</td>";
echo "<td width='20' align='center' id='I".$L."'>".$fila[8]."</td>";
echo "<td width='20' align='center' id='J".$L."'>".$fila[9]."</td>";
echo "</tr>";
$L++;
}
echo "</table>";
}else{
echo "<table id='tabladatos' border = '1'> \n";
echo "<tr>
<td></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>A</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>B</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>C</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>D</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>E</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>F</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>G</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>H</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>I</strong></td>
<td width='20' align='center' bgcolor='#CCCCCC'><strong>J</strong></td>
</tr>";

$H=1;
while ($H <6)
{
echo "<tr>";
echo "<td width='20' align='center' bgcolor='#CCCCCC'><strong>$H</strong></td>";
echo "<td width='20' align='center' id='A".$H."'></td>";
echo "<td width='20' align='center' id='B".$H."'></td>";
echo "<td width='20' align='center' id='C".$H."'></td>";
echo "<td width='20' align='center' id='D".$H."'></td>";
echo "<td width='20' align='center' id='E".$H."'></td>";
echo "<td width='20' align='center' id='F".$H."'></td>";
echo "<td width='20' align='center' id='G".$H."'></td>";
echo "<td width='20' align='center' id='H".$H."'></td>";
echo "<td width='20' align='center' id='I".$H."'></td>";
echo "<td width='20' align='center' id='J".$H."'></td>";
echo "</tr>";
$H++;
}
echo "</table>";
}
?>

luego regenero los datos desde una función javascript igual a:

function lotto(){
var totalnumbers=10 //total de numeros a generar
var lowerbound=1 //limite inferior
var upperbound=99 //limite superior
var brd = document.getElementById("tabladatos");
B=' ';
LottoNumbers=new Array();
for (i = 1; i <= totalnumbers; i++)
{
RandomNumber = Math.round(lowerbound+Math.random()*(upperbound-lowerbound));
for (j = 1; j <= totalnumbers; j)
{
if (RandomNumber == LottoNumbers[j])
{
RandomNumber=Math.round(lowerbound+Math.random()*( upperbound-lowerbound));
j=0;
}
j++;
}
LottoNumbers[i]=RandomNumber;
}
LottoNumbers=LottoNumbers.toString();
X=LottoNumbers.split(',');
for (i=0; i < X.length; i++)
{
X[i]=X[i];
if (X[i].length==1)
X[i]='0'+X[i];
}
for (i=1; i < X.length; i++)
{
//esta línea modifica los valores en cada celda (total=50 datos)
brd.rows[$filas].cells[i].innerHTML = X[i];
}
}

Lo que necesito es poder referenciar los datos nuevos, desde sus respectivas celdas, para almacenarlos en la base de datos con un update.

He intentado utilizar array php y array javascript, pero no he logrado traspasar los datos entre javascript y php.

La actualización se realiza en otro archivo php de control.

Ojalá pudiras orientarme con un poco de código,