This worked the magic for me.
<?php
$dbLink = mysqli_connect('localhost', 'usr', 'passd');
mysqli_select_db('edudata', $dbLink);
$mytableselect=$_POST['mytableselect'];
$sql = "SELECT * FROM $mytableselect";
$result = mysqli_query($sql) or die(mysqli_error());
// Print the column names as the headers of a table
echo "<table><tr>";
for($i = 0; $i < mysqli_num_fields($result); $i++) {
$field_info = mysqli_fetch_field($result, $i);
echo "<th>{$field_info->name}</th>";
}
// Print the data
while($row = mysqli_fetch_row($result)) {
echo "<tr>";
foreach($row as $_column) {
echo "<td>{$_column}</td>";
}
echo "</tr>";
}
echo "</table>";
?>
solved Use Php dropdown values to select mysql tables