0

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.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by cereal
2

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)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.