Hi,

I want to display my database, however I cannot used the conventional method (like this http://www.siteground.com/tutorials/php-mysql/display_table_data.htm )as the structure is unkown.

The user of the system can create and delete columns.

Does anyone know how I would be able to display the columns with the stored data?

If this helps, I can select the column names from information_schema:

SELECT column_name FROM information_schema.columns where table_name='tablename'";

Any help would be appreciated. Thanks.

Have you tried explain? For example:

mysql> explain users;
+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| id      | int(9)      | NO   | PRI | NULL    | auto_increment |
| fname   | varchar(50) | NO   |     | NULL    |                |
| lname   | varchar(50) | NO   |     | NULL    |                |
| userid  | varchar(50) | NO   |     | NULL    |                |
| referer | varchar(50) | NO   |     | NULL    |                |
+---------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

You can also use show create table users\G that will output additional data:

mysql> show create table users\G
*************************** 1. row ***************************
       Table: users
Create Table: CREATE TABLE `users` (
  `id` int(9) NOT NULL AUTO_INCREMENT,
  `fname` varchar(50) NOT NULL,
  `lname` varchar(50) NOT NULL,
  `userid` varchar(50) NOT NULL,
  `referer` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.