I am seeking a PHP code to fetch and retrieve data from a single column from a mysql table and display in a tabular form on the page. So I need a dropdown option list for the column names so every time a different column is selected, the relevant data is displayed on the page. Can someone provide me a code snippet or help me out with this, please? thanks.
I inserted an example image to show how it’d look. But it my case, i just need to display one column instead of multiple columns.
I would query the database table for column names - it should be fairy simple,(google ).
Then use the column names as values in ,select, tag.
I am not sure if you can get what you want just by selecting a column name from dropdown option list, perhaps a submit button need adding.
Upon clicking on ,submit, the code then should grab $_POST for that dropdown list (select tag), feed the value from $_POST to query which should be built to retrieve data only for that column.
thanks, guys. I tried your suggestions already actually. but I couldn’t make it work, so trashed it. So I was hoping to get a code snippet here. I googled a lot but couldn’t find something like that. so decided to ask experts. thanks for your suggestions.