I’m trying to write a PHP function that will output all fields in HTML for many different database tables. The tables vary in rows and also in columns, so I’m trying to come up with a method.
Like the example here – How get all values in a column using PHP?
If I don’t know how many columns are in each row in the database, or their names, though, how can I output the data from a "SELECT * FROM $mytable" query when each database varies in columns AND rows?
Maybe something like this?
UPDATE
Since this answer still seems to be getting some attention, I feel that it warrants noting that it since it is based on an example (linked in the original question) that is now outdated, this answer itself is also outdated. This is due to the use of the
mysqlextension which is now deprecated/removed (depending on your version of PHP). Instead, you should be using PDO or mysqli