Reputation: 373
i have a data (in tabular form) that look like as follows
1 2 3
4
5 0 6
8
This table contains three column and four rows and 12 cells.but all cells do not have value.i have stored data in this table to a database entering zero in the place of empty cells. but it result in the wastage of lot of space in database. I need to enter only non-zero values to my database and must be shown as the above table when retrieved.
Upvotes: 0
Views: 201
Reputation: 59699
This seems pretty simple:
Store the row
and column
values in their own separate columns, along with a value
column that holds the cell value.
You'll never enter non-zero or blank database values.
When you retrieve the values, populate them into a multidimensional array:
$table[ $row['row'] ][ $row['col'] ] = $row['value'];
Upvotes: 2