Código PHP:
Y lo uso así:Ver original
require_once 'dbConnect.php'; class cColegios { static private $instance; private $conn; private $result; const TABLA_COLEGIOS = "colegios"; //Constructor private function __construct() { $this->conn = Database::singleton(); } public static function singleton() { $miclase = __CLASS__; self::$instance = new $miclase; } return self::$instance; } public function showColegiosRegistrados() { try { $sql = "SELECT codigo, ruc, nombre, telefono1, email FROM " . self::TABLA_COLEGIOS . " WHERE estado = 1"; $query = $this->conn->prepare( $sql ); $query->execute(); if ( $query->rowCount() > 0 ) { while ( $row = $query->fetch( PDO::FETCH_NUM ) ) { $this->result .= '<tr> <td>' . $row[ 1 ] . '</td> <td>' . $row[ 2 ] . '</td> <td>' . $row[ 3 ] . '</td> <td>' . $row[ 4 ] . '</td> <td> <a href="#" class="btn btn-danger btn-xs" data-toggle="tooltip" data-placement="top" title="No Contactado">NC</a> <a href="#" class="btn btn-warning btn-xs md-trigger" data-modal="detailModalRegistrado" data-toggle="tooltip" data-placement="top" title="Ver detalles"><i class="fa fa-search"></i></a> </td> </tr>'; } } else { $this->result = '<tr><td colspan="5">No hay colegios registrados.</td></tr>'; } } catch ( PDOExeption $e ) { $this->result = 'Error: ' . $e->getMessage(); } return $this->result; } }
Código PHP:
Las filas si las muestra, pero arriba de la tabla me sale un mensaje que dice así:Ver original
<?php require_once 'inc/class/colegios.php'; $vCole = cColegios::singleton(); ?> <div class="table-responsive"> <table class="table table-hover table-striped"> <thead> <tr> <th>RUC</th> <th>Nombre</th> <th>Teléfono</th> <th>Email</th> <th>Estado</th> </tr> </thead> <tbody> <?php echo $vCole->showColegiosRegistrados(); ?> </tbody> </table> </div>
Código PHP:
Ver original