Avatar ·

How to get table column names in MySQL via PHP?

Hello everyone! I'm a beginner PHP developer, building an admin panel for a small online store. I need to display a list of products in a table, but I don't want to hardcode column names in HTML because the table may change (new fields for attributes are added). I have a simple query: ```php $query = "SELECT * FROM products"; $result = mysqli_query($link, $query); while ($row = mysqli_fetch_assoc($result)) { // here I output the data } ``` The problem is that I can only output the data, but I don't know how to dynamically get the column names (e.g., id, name, price, category_id). I tried using `mysqli_fetch_fields()`, but it didn't work — either the syntax was wrong or I'm calling the wrong function. I need a solution in pure PHP (prefer