Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. PARTE Dbase.php
  2. ---------------
  3. <?php
  4. class db
  5. {
  6.   //ATRIBUTOS
  7.   private $host="localhost";
  8.   private $user="root";
  9.   private $pass="";
  10.   private $db_name="nba";
  11.  
  12.   //CONECTOR
  13.   private $conexion;
  14.  
  15.   //PROPIEDADES CONTROL ERRORES
  16.   private $error=false;
  17.  
  18.   function __construct()
  19.   {
  20.       $this->conexion = new mysqli($this->host, $this->user, $this->pass, $this->db_name);
  21.       if ($this->conexion->connect_errno){
  22.         $this->error=true;
  23.       }
  24.   }
  25.  
  26.   //FUNCION PARA SABER SI HAY ERRORES
  27.  
  28.   function hayError(){
  29.     return $this->error;
  30.   }
  31.   public function devolverEquiposConf($conferencia){
  32.     if($this->error==false){
  33.       $resultado = $this->conexion->query("SELECT nombre,conferencia FROM equipos WHERE conferencia= '".$conferencia."'");
  34.       return $resultado;
  35.     }else{
  36.       return null;
  37. }
  38. }
  39. }
  40.  ?>
  41.  
  42. FILTRADO PHP
  43. ------------------
  44. <!DOCTYPE html>
  45. <html>
  46. <head>
  47.     <title>Filtrado</title>
  48. </head>
  49. <body>
  50. <form>
  51. <?php  
  52. //CONEXIONES A LAS DB
  53. include "dbase.php";
  54. //COMPROBACIÓN DE $_POST
  55. if(isset($_POST["conferencia"])&& !empty($_POST["conferencia"])){
  56. //CREAR NUEVO OBJETO, CON NOMBRE DE LA CLASE
  57. $nba=new db();
  58. $resultado=$nba->devolverEquiposConf($_POST["conferencia"]);
  59. while ($fila=$resultado->fetch_assoc()){
  60.     echo "nombre del equipo de la conferencia ".$fila["conferencia"]. " : " .$fila["nombre"] . "<br>";
  61. }
  62. }else{
  63. ?>
  64. <a href="index20.php">NO ME HAS ENVIADO NADA</a>
  65.  
  66. <?php
  67. }
  68.  
  69. ?>
  70. </form>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement