SHARE
TWEET

Untitled

a guest Jul 17th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class ConectarBD{
  3. private $servidor;
  4. private $basedatos;
  5. private $usuario;
  6. private $clave;
  7. private $conexion;
  8.  
  9.  
  10.  public function ConectarBD($ser,$bd,$usu,$cla){
  11.   $this->servidor=$ser;
  12.   $this->basedatos=$bd;
  13.   $this->usuario=$usu;
  14.   $this->clave=$cla;
  15.  }
  16.  
  17. public function EstablecerConexion(){
  18.   $this->conexion = new mysqli($this->servidor, $this->usuario, $this-
  19.   >clave,  $this->basedatos);
  20. }
  21.  
  22.  
  23. public function CerrarConexion(){
  24.   mysqli_close($this->conexion);
  25.  }
  26.  
  27.   public function InsertarHobbies($codigoHob, $nombreHob){
  28.     if ( $codigoHob !="" && $nombreHob !="" ) {
  29.       $insercion= "insert into tbhobbies values($codigoHob, '$nombreHob')";
  30.     }if ($this->conexion->query($insercion)===TRUE){
  31.         echo "REGISTRO GUARDADO";
  32.      }else{
  33.       echo "Error $insercion<br>". $this->conexion->error;
  34.        }
  35.  
  36.   }
  37.  
  38.  public function ConsultarRegistros(){
  39.    $consulta = "SELECT * FROM tbhobbies ORDER BY codigoHob";
  40.    $registros = $this->conexion->query($consulta);
  41.    $totalfilas=mysqli_num_rows($registros);
  42.    $color="#CCFFCC";
  43.    echo"<table>";
  44.    while ($filasvector= $registros->fetch_array(MYSQLI_ASSOC)) {
  45.         if($color == "#CCFFCC"){
  46.             $color ="#00F2CC";
  47.         }else{
  48.             $color="#CCFFCC";
  49.         }
  50.         echo "<tr bgcolor="."$color>";
  51.         echo "<td>";
  52.         echo $filasvector['codigoHob'];
  53.         echo "</td>";
  54.  
  55.         echo "<td>";
  56.         echo $filasvector['nombreHob'];
  57.         echo "</td>";
  58.         echo "</tr>";
  59.  
  60.     }
  61.     echo "</table";
  62.     $registros->free();
  63.  }
  64.  
  65.  
  66.  
  67. }
  68.   ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top