D
discussions
Hello all,
I would like some advice how best to approach the following problem. I
have "sort of" solved it but in a very horrible and complex way, I'm
sure there's a better, simple and more elegant way, but I just can't
see it.
The problem is as follows...
I have a list of items that are of the following types: A, B, C and D.
(There could be more in the future.) On my page I have a 4x4 grid (a
table) which I will fill with these items. Each row can only contain
items of the same type, i.e. you cannot mix types within a single row.
Each row will contain a maximum of 3 items and the last "hole" will
display a branding image. If there are less than 3 items of a single
type exist, the remaining "holes" in the row will be filled with more
branding images. It is important to show all the types even if only one
item exists for that type.
I get the count of each item from the DB. I am not sure what the count
will be. In the ideal world I will have 3 of A, 3 of B, 3 of C and 3 of
D. Therefore I can insert one item in each cell (each row representing
a single type) and insert 1 image. However, things don't usually work
out that way!! If no items exist for a particular type I will just show
more items of a type that does. I want to make sure that the spare rows
are filled evenly, i.e. shared among the types that have extra items.
Some examples...
1. If there are 12 of A and 1 of B my grid will show the following:
(I is an image)
AAAI
AAAI
AAAI
BIII
If there are 12 of A and 4 of B, the grid will show the following:
AAAI
AAAI
BBBI
BIII
If there are 12 of A, 4 of B and 1 of C the grid will show the
following:
AAAI
AAAI
BBBI
CIII
(It can be assumed that we can work through the items in the following
order, A, B, C and D)
Thanks,
Jose
I would like some advice how best to approach the following problem. I
have "sort of" solved it but in a very horrible and complex way, I'm
sure there's a better, simple and more elegant way, but I just can't
see it.
The problem is as follows...
I have a list of items that are of the following types: A, B, C and D.
(There could be more in the future.) On my page I have a 4x4 grid (a
table) which I will fill with these items. Each row can only contain
items of the same type, i.e. you cannot mix types within a single row.
Each row will contain a maximum of 3 items and the last "hole" will
display a branding image. If there are less than 3 items of a single
type exist, the remaining "holes" in the row will be filled with more
branding images. It is important to show all the types even if only one
item exists for that type.
I get the count of each item from the DB. I am not sure what the count
will be. In the ideal world I will have 3 of A, 3 of B, 3 of C and 3 of
D. Therefore I can insert one item in each cell (each row representing
a single type) and insert 1 image. However, things don't usually work
out that way!! If no items exist for a particular type I will just show
more items of a type that does. I want to make sure that the spare rows
are filled evenly, i.e. shared among the types that have extra items.
Some examples...
1. If there are 12 of A and 1 of B my grid will show the following:
(I is an image)
AAAI
AAAI
AAAI
BIII
If there are 12 of A and 4 of B, the grid will show the following:
AAAI
AAAI
BBBI
BIII
If there are 12 of A, 4 of B and 1 of C the grid will show the
following:
AAAI
AAAI
BBBI
CIII
(It can be assumed that we can work through the items in the following
order, A, B, C and D)
Thanks,
Jose