I have the index that contains my call of class CRUD
and foreach
calling the method of class crud
. But within foreach
I'm trying to pass the table name parameter, but it does not show anything. If I take the parameter and put the table name inside the method, it works fine. I do not know what to do! = /
Index:
<?php
require_once('classes/crud.class.php');
$mostrarpar = new crud();
?>
<?php foreach ($mostrarpar->Listar('moedas_par') as $res) { ?>
<li><?php echo $res['par_nome']; ?></li>
<?php } ?>
CRUD:
public function Listar($table) {
$this->query = $this->setConn()->prepare("SELECT * FROM'.$table.'");
$this->query->execute();
return $this->query->fetchall(PDO::FETCH_ASSOC);
}