Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PARTE Dbase.php
- ---------------
- <?php
- class db
- {
- //ATRIBUTOS
- private $host="localhost";
- private $user="root";
- private $pass="";
- private $db_name="nba";
- //CONECTOR
- private $conexion;
- //PROPIEDADES CONTROL ERRORES
- private $error=false;
- function __construct()
- {
- $this->conexion = new mysqli($this->host, $this->user, $this->pass, $this->db_name);
- if ($this->conexion->connect_errno){
- $this->error=true;
- }
- }
- //FUNCION PARA SABER SI HAY ERRORES
- function hayError(){
- return $this->error;
- }
- public function devolverEquiposConf($conferencia){
- if($this->error==false){
- $resultado = $this->conexion->query("SELECT nombre,conferencia FROM equipos WHERE conferencia= '".$conferencia."'");
- return $resultado;
- }else{
- return null;
- }
- }
- }
- ?>
- FILTRADO PHP
- ------------------
- <!DOCTYPE html>
- <html>
- <head>
- <title>Filtrado</title>
- </head>
- <body>
- <form>
- <?php
- //CONEXIONES A LAS DB
- include "dbase.php";
- //COMPROBACIÓN DE $_POST
- if(isset($_POST["conferencia"])&& !empty($_POST["conferencia"])){
- //CREAR NUEVO OBJETO, CON NOMBRE DE LA CLASE
- $nba=new db();
- $resultado=$nba->devolverEquiposConf($_POST["conferencia"]);
- while ($fila=$resultado->fetch_assoc()){
- echo "nombre del equipo de la conferencia ".$fila["conferencia"]. " : " .$fila["nombre"] . "<br>";
- }
- }else{
- ?>
- <a href="index20.php">NO ME HAS ENVIADO NADA</a>
- <?php
- }
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement