note 113813 deleted from function.pos by aharvey
| From: | aharvey@php.net | Date: | Thu, 05 Dec 2013 22:15:17 +0000 |
| Subject: | note 113813 deleted from function.pos by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197768@lists.php.net to get a copy of this message | ||
Note Submitter: javet71 at hotmail dot com
----
<?php
// Nos conectamos al servidor de base de datos
mysql_connect("localhost", "examen", "examen2012");
// Seleccionamos la base de datos
mysql_select_db("examen");
// Ejecutamos la sentencia SQL ...
$sql = "select * from uf where fecha = current_date()";
$resp = mysql_query($sql);
// ... y obtenemos la fila resultante
$fila = mysql_fetch_assoc($resp);
// Obtenemos el valor de la UF
$uf = $fila["valor"];
// Obtenemos el factor en caso de ser hombre
if ($_POST["sexo"] == "m") {
if ($_POST["edad"] >= 18 && $_POST["edad"] <= 29) {
$factor = 0.8;
}
if ($_POST["edad"] >= 30 && $_POST["edad"] <= 49) {
$factor = 1.1;
}
if ($_POST["edad"] >= 50 && $_POST["edad"] <= 59) {
$factor = 2.3;
}
if ($_POST["edad"] >= 60) {
$factor = 3.9;
}
}
// Obtenemos el factor en caso de ser mujer
if ($_POST["sexo"] == "f") {
if ($_POST["edad"] >= 18 && $_POST["edad"] <= 29) {
$factor = 2.0;
}
if ($_POST["edad"] >= 30 && $_POST["edad"] <= 49) {
$factor = 3.0;
}
if ($_POST["edad"] >= 50 && $_POST["edad"] <= 59) {
$factor = 1.0;
}
if ($_POST["edad"] >= 60) {
$factor = 4.0;
}
}
// Calculamos el valor del plan en UF
$plan_uf = 1.5 * $factor;
// Calculamos el valor del plan en pesos
$plan_pesos = $plan_uf * $uf;
?>
<!doctype html>
<html>
<head>
<title>Valor Plan de Salud</title>
</head>
<body>
<h3>Valor Plan de Salud</h3>
<h4>Estimado(a) <?php print $_POST["nombre"]; ?>, el costo de su plan de salud
es de <?php print $plan_uf; ?> UF lo que equivale a $<?php print $plan_pesos;
?></h4>
</body>
</html>
<?php
mysql_close();
?>