Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/03/2010, 12:48
benjaminvera
 
Fecha de Ingreso: junio-2008
Mensajes: 101
Antigüedad: 15 años, 11 meses
Puntos: 0
Cómo incrementar una variable en una sentencia MySQL desde PHP...???

Tengo el siguiente script y lo que hace es que mediante una colomna de HTML llamada Modificar solo contiene un CheckBox por Registro y a la hora de habilitar el CheckBox debe de mostrar por medio de un Input Text Box el valor extraido para posteriormente ser modificado....

El código PHP que me muestra la tabla es el siguiente

Código PHP:
$numero_filas=mysql_query("select count(*) as cantidad from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005';",$conexion) or
  die(
"Problemas en el select:".mysql_error());

$inicio=1;
$celda=-1;$celda<=$numero_filas['cantidad'];$celda++;
$valor mysql_query("select valor from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005' limit {$celda},1;",$conexion) or
  die(
"Problemas en el select:".mysql_error());

    echo 
"<table border=1><tr>";
    echo 
"<tr><td>columna 1<td>columna 2<td>columna 3<td>columna 4</tr>";
while(
$inicio<=$numero_filas)
{
    echo 
"<tr><td>Hola, cómo estás número: ".$inicio."</td>";                                                         // columna 1 
    
echo "<td><input type=\"text\" id=\"box_".$inicio."\"style=\"visibility: hidden;\" />";                            // columna 2
    
echo "<input type=\"checkbox\" name=\"box_".$inicio."\" onclick=\"muestra(this)\" /></td>";                        // columna 2
    
echo "<td><input type=\"text\" id=\"boxy".$inicio."\"style=\"visibility: hidden;\" value=\"";
    
$row mysql_fetch_assoc($valor);
    echo 
$row['valor']."\">";                                                                                        // columna 3
    
echo "<input type=\"checkbox\" name=\"boxy".$inicio."\" onclick=\"muestra(this)\" /></td>";// columna 3
while ($row mysql_fetch_row($result))
{
    echo 
"<TD>".str_replace(-0.001,"Sin valor",$row['valor'])."</TD>";                                                // columna 4
}

    
$inicio++;
    
$celda++;
}
    echo 
"</tr></table>";
    echo 
"<table><tr>"
Para que sea un poco más claro lo que necesito hacer pongo un poco de código SQL....

Código MySQL:
Ver original
  1. mysql> select valor from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005' limit 0,1;
  2. +--------+
  3. | valor  |
  4. +--------+
  5. | -0.001 |
  6. +--------+
  7. 1 row in set (0.00 sec)
  8.  
  9. mysql> select valor from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005' limit 1,1;
  10. +-------+
  11. | valor |
  12. +-------+
  13. | 12.12 |
  14. +-------+
  15. 1 row in set (0.01 sec)
  16.  
  17. mysql> select valor from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005' limit 12,1;
  18. +-------+
  19. | valor |
  20. +-------+
  21. |  1.01 |
  22. +-------+
  23. 1 row in set (0.00 sec)
  24.  
  25. mysql> select valor from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005' limit 13,1;
  26. Empty set (0.02 sec)
  27.  
  28. mysql> select valor from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005';
  29. +--------+
  30. | valor  |
  31. +--------+
  32. | -0.001 |
  33. |  12.12 |
  34. |  11.11 |
  35. |   10.1 |
  36. |   9.09 |
  37. |   8.08 |
  38. |   7.07 |
  39. |   6.06 |
  40. |    5.5 |
  41. |   4.04 |
  42. |   3.03 |
  43. |   2.02 |
  44. |   1.01 |
  45. +--------+
  46. 13 rows in set (0.00 sec)

Entonces como verán, lo que necesito hacer es una iteración en:

Código PHP:
$numero_filas=mysql_query("select count(*) as cantidad from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005';",$conexion) or
  die(
"Problemas en el select:".mysql_error());

$inicio=1;
$celda=-1;$celda<=$numero_filas['cantidad'];$celda++;
$valor mysql_query("select valor from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005' limit {$celda},1;",$conexion) or
  die(
"Problemas en el select:".mysql_error()); 
Código MySQL:
Ver original
  1. mysql> select count(*) as cantidad from loba where nomb_pla='Bubulubu' and nomb_cen='Conejos'  and mes='Ene' and ano='2005';
  2. +----------+
  3. | cantidad |
  4. +----------+
  5. |       13 |
  6. +----------+
  7. 1 row in set (0.00 sec)