Chestia asta preia din orice tabela mai intai header-ul, apoi toate inregistrarile si le afiseaza intr-un tabel.
Este foarte potrivita pentru o afisare a bazei de date pentru ca nu trebuie sa mai scrieti peste tot $rand['nume' ,$rand['prenume....etc...
Modificati-o pentru a fi compatibila cu cerintele voastre. Sau numele campului ce selecteaza tabelul din Baza de date sa se numeasca "t".
$_SESSION['table']=$_POST['t'];
$tabel=$_SESSION['table'];
$result = mysqli_query($_SESSION['con'],"SELECT * FROM $tabel");
$e = mysqli_num_fields($result);
$tabel=$_SESSION['table'];
$result = mysqli_query($_SESSION['con'],"SELECT * FROM $tabel");
$e = mysqli_num_fields($result);
echo "<table border='1'>";
$i = 0;
echo "<tr>";
while($i<$e)
{
$meta=mysqli_fetch_field($result);
$i = 0;
echo "<tr>";
while($i<$e)
{
$meta=mysqli_fetch_field($result);
echo "<th>".$meta->name."</th>";
$i++;
}
echo "</tr>";
$i++;
}
echo "</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
for($i=0;$i<$e;)
{
echo "<td>" . $row[$i] . "</td>";
$i++;
}
echo "</tr>";
}
echo "</table>";
{
echo "<tr>";
for($i=0;$i<$e;)
{
echo "<td>" . $row[$i] . "</td>";
$i++;
}
echo "</tr>";
}
echo "</table>";