Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Visualizing arrays with a basic computing problem

datastructures

New Coder
I have something that has been bugging me for a while now. From the wikipedia entry on arrays

Because the mathematical concept of a matrix can be represented as a two-dimensional grid, two-dimensional arrays are also sometimes called matrices.

This is the wikipedia page https://en.wikipedia.org/wiki/Array_data_structure.

Take a simple mysql table with the following fields

id, product_name, product_description, product_category,date_updated

The table has products in it and i want to query this table and i want to display the product category as the header and then list the products under the header.

This is the representation in the GUI

For instance i have the following categories i.e tvs, tables, utensils

tvs

product 1
product 2
product 3

tables

product 4
product 5
product 6

utensils

product 7
product 8
product 9


My mysql query would look like this

Code:
select * from products order by product_category


I am looking for various snippets on how you can achieve the display as i have described above. I am also looking for various ways you can do this and an explanation as well.

Objectives

Since arrays are stored in contiguous blocks of memory Source: arrays i am trying to wrap my head around the idea of arrays being matrices. Code can be in python or php or javascript and the explanation is what i am most interested in.

Thanks.
 
Back
Top Bottom