0

I'd like to get all of a mysql table's col names in a select box, and display the selected column name in a table. I just want to select one column at a time to display it in a single column table. I am assuming this can be done with a single query for all columns because they all will be displayed in the same table format. What I did so far is this:

<html> <head> </head> <body> <table id="tbresult"> <tr> <th>Column</th> </tr> <?php

include ("config.php");

$sql = "SHOW COLUMNS FROM mytable";

$result = mysqli_query($conn,$sql);

while($row = mysqli_fetch_array($result)){
 echo "<tr><td>" . $row["Column"] ."</td></tr>";
}

    echo "</table>";

} else { echo "0 results"; }
$conn->close();

    ?> </table>

Edited by Mati_1

1
Contributor
0
Replies
56
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.