Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/04/2010, 09:21
maxwellxp
 
Fecha de Ingreso: abril-2010
Mensajes: 143
Antigüedad: 14 años
Puntos: 0
Respuesta: problema code PHP

Código HTML:
<?php
if(isset($_POST['noticia'])) {
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$numres = $num1 + $num2;
mysql_connect("localhost","root") or die ("no se pudo conectar");
mysql_select_db("prueba");
mysql_query("UPDATE numero SET sumatoria = sumatoria + 1") or die(mysql_error());
mysql_query("INSERT INTO numero (num1, num2, resultado) VALUES ('$num1', '$num2', '$numres')") or die(mysql_error());
$query2 = mysql_query("SELECT * FROM numero") or die(mysql_error());
while ($row = mysql_fetch_array($query2)) {
$sumador = $row['sumatoria'];
}
$query = mysql_query("SELECT * FROM numero WHERE id=$sumador") or die(mysql_error());
while ($res = mysql_fetch_array($query)) {
$num1_b = $res['num1'];
$num2_b = $res['num2'];
$numres_b = $res['resultado'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <p>
    <label>
    <input type="text" name="num1" id="num1" />
    </label> 
    + 
    <label>
    <input type="text" name="num2" id="num2" />
    </label>
    <input type="submit" name="noticia" id="noticia" value="Enviar" /></p>
  <p>Resultado actual:
    <?php if(isset($_POST['noticia'])) { echo $numres; } ?>
  </p>
<p>Operadores Anteriores: <?php if(isset($_POST['noticia'])) { echo $res['num1']; } ?> + <?php if(isset($_POST['noticia'])) { echo $res['num2']; } ?></p>
    <p> Resultado anterior: <?php if(isset($_POST['noticia'])) { echo $res['resultado']; }?></p>

  <label></label>
</form>
</body>
</html> 
listo, pero no tira ningun error en ejecucion...