MySQL和PHP的矩阵

i want to make a matrix with MySQL and PHP, but somehow i don't know how to make it simple for me. I have two datatables:

id_car
car

AND

id_extra
extra

And a last database which has both ids from previous tables:

id_car
id_extra

there should be a matrix (table) that shows for one special car (for example BMW) every extra that he has.

on the top there are the different car brands and on the left side there are the extras what the cars have. the matrix shows which extra the car brands have.

                  | BMW | FERRARI | RENAULT |
red               | NO  |    YES  |   YES   |
sunroof           | YES |    NO   |   YES   |
central locking   | YES |    YES  |   YES   |
heated seats      | YES |    NO   |   NO    |

can you give me some hints, how to best get such a matrix? maybe you can give me a better solution for the database?!

since you asked about better solutions...

this is generally considered an SQL antipattern called Entity-Attribute-Value

http://mikesmithers.wordpress.com/2013/12/22/the-anti-pattern-eavil-database-design/

the above link will tell you why it's bad, what you should do instead and give you the full implementation of your view should you decide to stick with it.

TLDR;

are you sure you can't just put the "extras" as boolean fields in the car table?