Error showing a query to the database with php

0

I want to show in a select tag a base table using mvc classes or model, but I do not understand why I get this error.

  

Notice: Trying to get property 'num_rows' of non-object in /opt/lampp/htdocs/php/projectPhp/model/Videojuegos.php on line 240   bool (false)

     

Warning: Invalid argument supplied for foreach () in /opt/lampp/htdocs/php/projectPhp/formularios/formVideojuegos.php on line 112

The issue is that only one of the select that shows me works but the other select does not.

The class where I do the consultations:

public function mostrarIdioma(){
    $con = $this->conectar();
    $sql ="SELECT * FROM idioma";

    $info2 = $con->query($sql);

    if($info2->num_rows>0){
        $data2 = $info;
    }else{
        $data2 = false;
    }
    return $data2;

}
public function mostrarPlataforma(){
    $con = $this->conectar();
    $sql ="SELECT * FROM plataforma";

    $info = $con->query($sql);

    if($info->num_rows>0){
        $data = $info;
    }else{
        $data = false;
    }
    return $data;
}

public function mostrarClacificacion(){
    $con = $this->conectar();
    $sql ="SELECT * FROM catagoria";

    $info = $con->query($sql);

    if($info->num_rows>0){
        $data = $info;
    }else{
        $data = false;
    }
    return $data;
}

Here is where it shows:

<div class="col-md-3">
        <label>Plataforma:</label>
        <select name="plataforma" id="plataforma" class="form-control">
            <option value="0">.::::Elija una opcion::::.</option>
    <?php
                $objPlataforma = new Videojuegos();
                $data= $objPlataforma->mostrarPlataforma();
        foreach ($data as $value) { 
    ?>
          <option value="<?php echo $value['idPlataforma']; ?>"><?php echo $value['nombrePlataforma']; ?></option>
          <?php                                 
            }
          ?>    
        </select>
    </div>
    </div><!-- FINAL ROW -->
    <div class="row">
        <div class="col-md-3">
            <label>Idioma:</label>
            <select name="idioma" id="idioma" class="form-control">
                <option value="0">.:::Elija una opcion:::.</option>
    <?php
                $objIdioma = new Videojuegos();
                $data2 = $objIdioma->mostrarIdioma();
                var_dump($data2);
                  foreach ($data2 as $value2) {
    ?>
          <option value="<?php echo $value2['idIdioma'];?>"><?php echo $value2['nombreIdioma']; ?></option>
    <?php
                }
    ?>  
    </select>

On the platform it does what it has to do that is to show me what is in the table and that they will have the value of the id of the table due to the relation with the videogame table that this id will help me to insert this data in the videogame table.

But in language I get the error that I showed earlier, how can I make it show?

    
asked by DagsDroid 28.04.2018 в 06:01
source

0 answers