以下是我到目前为止所拥有的。但它不输出任何东西。我不明白我做错了什么。我已经有一个称为页面结构的连接函数
class dataview extends PDO
{
public $dbh;
function prep($querytoprepare = null, $parameters = null)
{
$query = $this->dbh->prepare($querytoprepare);
if($parameters === null)
{
$query->execute();
}
else
{
$query->execute($parameters);
}
$query->fetchAll();
}
function getData()
{
$query = prep("SELECT * FROM table");
$table = "<table>";
foreach($query as $result
{
$table .= "<tr><td>" . $result['product_id'] . "</td><td>" . $result['naam'] . "</td><td>€" . $result['prijs'] . "</td></tr>";
}
$table .="</table>";
echo $table;
}
}
$x = new dataview();
$x->getData();