Foros del Web » Programando para Internet » PHP »

me pueden ayudar¿?

Estas en el tema de me pueden ayudar¿? en el foro de PHP en Foros del Web. Hola antes de nada; me llamo samuel y estoy empezando en esto del php. Estoy liao con una tonteria enorme pero no le veo la ...
  #1 (permalink)  
Antiguo 26/10/2010, 13:52
 
Fecha de Ingreso: octubre-2010
Mensajes: 1
Antigüedad: 13 años, 6 meses
Puntos: 0
me pueden ayudar¿?

Hola antes de nada; me llamo samuel y estoy empezando en esto del php.

Estoy liao con una tonteria enorme pero no le veo la solucion; es un if que no me responde o si me responde no es como yo quiero. os pongo el codigo y me deciis.

<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
//crear nombre de variables cortos
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
?>
<?php
$totalqty = 0;
if ( $totalqty != 0)
{

echo '<p>Order processed at ';
echo date('H:i, jS F');// funcion de calendario fecha y hora
echo '</p>';



echo '<p>Your order is as follows: </p>';
echo $tireqty.' tires<br />';
echo $oilqty.' bottles of oil<br />';
echo $sparkqty.' spark plugs<br />';



$totalqty = 0;
$totalamount = 0.00;

$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';

$totalamount = 0.00;

define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);

$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;

echo 'Subtotal: $'.number_format($totalamount,2).'<br />';

$taxrate = 0.10; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />'; /*number_format() funcion con el numero de decimales que le indiquemos, en este caso 2*/
}

else
{
echo 'no ha comprado nada';
}
?>
</body>
</html>

si le pongo el if ( $totalqty == 0) siempre me sale el mensaje(poniendo el mensaje en la condicion del if claro
  #2 (permalink)  
Antiguo 26/10/2010, 14:04
Avatar de Nano_  
Fecha de Ingreso: febrero-2006
Ubicación: Bogotá, Colombia
Mensajes: 1.866
Antigüedad: 18 años, 2 meses
Puntos: 96
Respuesta: me pueden ayudar¿?

Saludos

Por que codificas esto asi:

Código PHP:
Ver original
  1. $totalqty = 0;
  2. if ($totalqty != 0)

Nunca entrara al if!
__________________
:.:Nano.:: @nano_hard - Retornando al foro

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:38.