Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/07/2007, 12:29
Avatar de carmagedon
carmagedon
 
Fecha de Ingreso: junio-2005
Ubicación: Argentina
Mensajes: 794
Antigüedad: 18 años, 10 meses
Puntos: 23
Re: Alquien que me ayude con CALCULO PHP

Saludos, por aca te respondo.
Mira, ese es un ejemplo muy sencillo acerca de una calculadora, yo creo que dandole un poco al coco te sale:

Código:
<form action="" method="post">
<input name="first" type="text" size="6" maxlength="10">
<select name="method1">
	<option value="add" selected>Add</option>
	<option value="sub">Subtract</option>
	<option value="multi">Multiply</option>
	<option value="div">Divide</option>
</select>
<input name="second" type="text" size="6" maxlength="10">
<br><br>
<input name="submit1" type="submit" value="Calculate">
</form>
<?php
// Get variables from POST:
if (isset($_POST['submit1'])&& isset($_POST['submit2']) && isset($_POST['method1']) 
 && isset($_POST['method2']) && isset($_POST['first']) 
 && isset($_POST['second']) && isset($_POST['number'])){
$submit1 = $_POST['submit1'];
$submit2 = $_POST['submit2'];
$method1 = $_POST['method1'];
$method2 = $_POST['method2'];
$first = $_POST['first'];
$second = $_POST['second'];
$number = $_POST['number'];
}

// Simple
if ($submit1 == true) {
	switch ($method1) {
		case add: $ans = $first + $second;
		break;
		case sub: $ans = $first - $second;
		break;
		case multi: $ans = $first * $second;
		break;
		case div: $ans = $first / $second;
		break;
	}

$ans = number_format($ans, 2, ',', ' ');
echo "<p>The answer is $ans</p>";
}
Ese script lo saque de un rejunte de script que tengo recogido de internet, lo tuve que modificar porque tenia errores, asique por ahora funciona, no es todo el script de la calculadora, pero es para que tengas una idea..
Suerte che, cualquier cosa pregunta por aca ;)