As you can read in the title, I'm trying to create a generic function in order to generate a table from a mySQL database. I want to reuse it for every table I need to create in this project and for the next ones.
function table_generator($nameTable, $db) {
$requete = $db->prepare("SELECT * FROM " . $nameTable);
$requete->execute();
$i = '0';
foreach($requete AS $data) {
echo "<tr>";
foreach($data as $vars){
echo "<td>$vars</td>";
}
echo "</tr>";
}
}
Edit: the echo write every field twice.