PHP - 如何根据另一个行表创建一些列/字段

there's some way to create column depending by another row?

I mean like this :

example:

I have table A:

|----|----------|
| id | criteria |
|----|----------|
| 1  | column A |
| 2  | column B |
| 3  | column C |
| .. |    ...   |//column D, E, F, etc
|----|----------|

how to create a Table B like this?

|column A |column B |column C | ... |
|---------|---------|---------|-----|
|  value  |  value  |  value  |(etc)|
|   ...   |   ...   |   ...   | ... |
|---------|---------|---------|-----|

is it possible with PHP??

I don't know a keyword of this case, so if someone wanna give me a link, it would be appreciate

You can get Criteria from Table A by SELECt query, Assume that you know the SELECT Query, and after that based on result You can run loop for each Criteria get from table A. and for add column Use below query.

IF NOT EXISTS( SELECT NULL
            FROM INFORMATION_SCHEMA.COLUMNS
           WHERE table_name = 'tablename'
             AND table_schema = 'db_name'
             AND column_name = 'columnname')  THEN

  ALTER TABLE `TableName` ADD `ColumnName` varchar(255) ;

END IF;