Advertisement
Guest User

Untitled

a guest
Mar 8th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.17 KB | None | 0 0
  1. <?php
  2.  
  3. class Conexion {
  4.     private     $servername ;
  5.     private     $username ;
  6.     private     $password ;
  7.     private     $database ;
  8.     private     $table ;
  9.     private     $port ;
  10.     private     $link;
  11.  
  12.     function getServername() {
  13.         return $this->servername;
  14.     }
  15.  
  16.     function getUsername() {
  17.         return $this->username;
  18.     }
  19.  
  20.     function getPassword() {
  21.         return $this->password;
  22.     }
  23.  
  24.     function getDatabase() {
  25.         return $this->database;
  26.     }
  27.  
  28.     function getTable() {
  29.         return $this->table;
  30.     }
  31.  
  32.     function getPort() {
  33.         return $this->port;
  34.     }
  35.  
  36.     function setServername($servername) {
  37.         $this->servername = $servername;
  38.     }
  39.  
  40.     function setUsername($username) {
  41.         $this->username = $username;
  42.     }
  43.  
  44.     function setPassword($password) {
  45.         $this->password = $password;
  46.     }
  47.  
  48.     function setDatabase($database) {
  49.         $this->database = $database;
  50.     }
  51.  
  52.     function setTable($table) {
  53.         $this->table = $table;
  54.     }
  55.  
  56.     function setPort($port) {
  57.         $this->port = $port;
  58.     }
  59.    
  60.     function getLink() {
  61.         return $this->link;
  62.     }
  63.  
  64.     function setLink($link) {
  65.         $this->link = $link;
  66.     }
  67.  
  68.    
  69.    
  70.     function Conexion() {
  71.         echo ' <strong>Success!</strong> ';
  72.        
  73.    
  74.  
  75.    }
  76.  
  77.  function Conectar($host, $user, $password, $port, $Database, $table){
  78.      $this->setServername($host);
  79.       $this->setDatabase($Database);
  80.        $this->setPort($port);
  81.         $this->setUsername($user);
  82.          $this->setPassword($password);
  83.           $this->setTable($table);  
  84.           $this->setLink(mysqli_connect($this->getServername(), $this->getUsername(), $this->getPassword(), $this->getDatabase(), $this->getPort()));
  85.     return mysqli_connect_errno();
  86.  
  87.  }
  88.  
  89.   function addConsultorio ( $nombre, $peso, $estatura, $Imc, $gradoObesidad ){
  90.     $query = "INSERT INTO persona VALUES (null,'$nombre','$peso','$estatura','$Imc','$gradoObesidad')";
  91.     mysqli_query($this->getLink(), $query);
  92.  }
  93.      // }
  94.    
  95.    // function calcularImc($Imc,$peso, $estatura){
  96.        // $Imc=($peso)/($estatura*$estatura);
  97.        
  98.         //return $Imc;
  99.            
  100.    // }
  101.     function gradoObesidad($Imc){
  102.        
  103.        
  104.         if($Imc<18.5){
  105.             $gradoObesidad="Usted tiene Desnutrición";
  106.            
  107.         }else
  108.        
  109.         if($Imc>=18.5 && $im<=24.9){
  110.           $gradoObesidad= "Su peso es Normal";  
  111.            
  112.            
  113.         }else
  114.         if($Imc>=25 && $im<=29.9){
  115.           $gradoObesidad= "Usted tiene Sobrepeso";      
  116.        
  117.         }else
  118.         if($Imc>=30 && $im<=34.9){
  119.           $gradoObesidad= "Tiene un problema de Obesidad";      
  120.        
  121.         }else
  122.         if($Imc>=35 && $im<=39.9){
  123.           $gradoObesidad= "Tiene un problema de Obesidad Severa";      
  124.        
  125.         }else
  126.         if($Imc>=40){
  127.           $gradoObesidad= "obeso severo";      
  128.        
  129.         }  
  130.     return $gradoObesidad;
  131.    
  132.     }
  133.   function borrarConsultorio($id){
  134.      $query = "DELETE FROM persona WHERE ID =".$id;
  135.      mysqli_query($this->getLink(), $query);
  136.  }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement